tel

//
//  JZLTel.m
//  JZLIntegrationDemo
//
//  Created by 微指 on 15/3/16.
//  Copyright (c) 2015年 JZL. All rights reserved.
//

#import "JZLTel.h"

@implementation JZLTel

/*

#pragma mark - 打电话
-(void)callButtonAction
{
    
    NSString * phone1 = [self.phones objectAtIndex:0];
    NSString * phone2 = [self.phones objectAtIndex:1];
    NSString * name = self.shopname;
    NSMutableSet * phones = [NSMutableSet set];
    
    if (![phone1 isEqualToString:@""] && phone1) {
        
        [phones addObject:phone1];
    }
    
    if (![phone2 isEqualToString:@""] && phone2) {
        
        [phones addObject:phone2];
    }
    
    NSArray * phonesArray = [phones allObjects];
    if (phonesArray.count>1) {
        
        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"呼叫"
                                                         message:name
                                                        delegate:self
                                               cancelButtonTitle:@"取消"
                                               otherButtonTitles:nil];
        
        alert.tag = 500;
        
        for (int i=0; i<phonesArray.count; i++) {
            
            [alert addButtonWithTitle:[phonesArray objectAtIndex:i]];
        }
        [alert show];
        [alert release];
        
    } else if (phonesArray.count == 1) {
        
        UIWebView *callWebView = [[UIWebView alloc] init];
        NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",[phonesArray objectAtIndex:0]]];
        [callWebView loadRequest:[NSURLRequest requestWithURL:telURL]];
        [self.view addSubview:callWebView];
        [callWebView release];
    }
    
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex != 0) {
        
        NSString * title = [alertView buttonTitleAtIndex:buttonIndex];
        NSString * str = [NSString stringWithFormat:@"tel:%@",title];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    }
}
 */

@end

原文地址:https://www.cnblogs.com/jzlblog/p/4342497.html