iOS拨打电话的3种实现方式
更新时间:2018年06月24日 16:05:18 作者:iOS张文权
这篇文章主要介绍了iOS拨打电话的3种实现方式 ,非常不错,具有参考借鉴价值,需要的朋友可以参考下
iOS实现拨打电话的方式:
方法一、requestWithURL,此方法拨打前弹出提示
NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"tel:%@",@"136****0000"]; UIWebView * callWebview = [[UIWebView alloc] init]; [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]]; [self.view addSubview:callWebview];
swift代码:
let callWebview = UIWebView()callWebview.loadRequest(NSURLRequest(url: URL(string: "tel:136****0000")!) as URLRequest) self.view.addSubview(callWebview)
方法二、openURL(telprompt) ,此方法拨打前弹出提示,据说会导致App Store审核不通过
NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"telprompt:%@",@"136****0000"]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
swift代码:
方法三、利用openURL(tel),此方法在iOS 10.2之前不会添加弹框,需要自己处理,手动添加alert即可
NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"tel:%@",@"136****0000"]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
总结
以上所述是小编给大家介绍的iOS拨打电话的3种实现方式 ,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
相关文章
iOS自定义UICollectionViewLayout实现瀑布流布局
这篇文章主要为大家详细介绍了iOS自定义UICollectionViewLayout实现瀑布流布局,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2016-12-12iOS 9 更新之Safari广告拦截器(Content Blocker)开发教程
这篇文章主要介绍了iOS 9 更新之Safari广告拦截器(Content Blocker)开发教程的相关资料,需要的朋友可以参考下2015-08-08iOS UICollectionView刷新时闪屏的解决方法
本篇文章主要介绍了iOS UICollectionView刷新时闪屏的解决方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-11-11
最新评论