iOS拨打电话的3种实现方式
iOS实现拨打电话的方式:
方法一、requestWithURL,此方法拨打前弹出提示
NSMutableString*string=[[NSMutableStringalloc]initWithFormat:@"tel:%@",@"136****0000"]; UIWebView*callWebview=[[UIWebViewalloc]init]; [callWebviewloadRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:string]]]; [self.viewaddSubview:callWebview];
swift代码:
letcallWebview=UIWebView()callWebview.loadRequest(NSURLRequest(url:URL(string:"tel:136****0000")!)asURLRequest) self.view.addSubview(callWebview)
方法二、openURL(telprompt),此方法拨打前弹出提示,据说会导致AppStore审核不通过
NSMutableString*string=[[NSMutableStringalloc]initWithFormat:@"telprompt:%@",@"136****0000"]; [[UIApplicationsharedApplication]openURL:[NSURLURLWithString:string]];
swift代码:
方法三、利用openURL(tel),此方法在iOS10.2之前不会添加弹框,需要自己处理,手动添加alert即可
NSMutableString*string=[[NSMutableStringalloc]initWithFormat:@"tel:%@",@"136****0000"]; [[UIApplicationsharedApplication]openURL:[NSURLURLWithString:string]];
总结
以上所述是小编给大家介绍的iOS拨打电话的3种实现方式,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短