这篇文章主要介绍了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绘图组件之CustomPaint使用详解 2023-05-12
- Android开发使用RecyclerView添加点击事件实例详解 2023-06-15
- Android多返回栈技术 2023-04-15
- Flutter手势密码的实现示例(附demo) 2023-04-11
- iOS开发教程之XLForm的基本使用方法 2023-05-01
- android studio按钮监听的5种方法实例详解 2023-01-12
- IOS应用内跳转系统设置相关界面的方法 2022-11-20
- Android中的webview监听每次URL变化实例 2023-01-23
- IOS 播放系统提示音使用总结(AudioToolbox) 2023-03-01
- 解决Android Studio突然不显示logcat日志的问题 2023-02-04
