首页 > 代码库 > iOS 拨打电话的两种方式

iOS 拨打电话的两种方式

第一种方式 

NSString *phone = @“88888888”


    if (phone != nil) {

        

        NSString *telUrl = [NSString stringWithFormat:@"telprompt:%@",phone];

        

        NSURL *url = [[NSURL alloc] initWithString:telUrl];

        

        [[UIApplication sharedApplication] openURL:url];

}


第二种方式 


UIWebView*callWebview =[[UIWebView alloc] init];

         NSString *telUrl = [NSString stringWithFormat:@"tel:%@",phone];

         NSURL *telURL =[NSURL URLWithString:telUrl];// 貌似tel:// 或者 tel: 都行

         [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];

         //记得添加到view

         [self.view addSubview:callWebview];


iOS 拨打电话的两种方式