这篇文章主要介绍了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拨打电话的3种实现方式
猜你喜欢
- 详解flutter engine 那些没被释放的东西 2022-12-04
- Android实现监听音量的变化 2023-03-30
- 最好用的ios数据恢复软件:PhoneRescue for Mac 2023-09-14
- iOS 对当前webView进行截屏的方法 2023-03-01
- Android实现轮询的三种方式 2023-02-17
- Flutter实现底部和顶部导航栏 2022-08-31
- Android MaterialButton使用实例详解(告别shape、selector) 2023-06-16
- Android studio实现动态背景页面 2023-05-23
- 作为iOS开发,这道面试题你能答出来,说明你基础很OK! 2023-09-14
- SurfaceView播放视频发送弹幕并实现滚动歌词 2023-01-02
