iOS
来源:互联网 发布:淘宝违法店铺举报 编辑:程序博客网 时间:2024/06/01 09:59
拨打电话的方式总结
方式一
用法
/** cell的自定义代理方法 @param leaveListCell cell @param phone 电话号码 */- (void)leaveListCell:(ZDTLeaveListCell *)leaveListCell phoneCall:(NSString *)phone{ //拨打电话代码 NSMutableString * phoneStr=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",phone]; NSURL *phoneUrl = [NSURL URLWithString:phoneStr]; dispatch_async(dispatch_get_global_queue(0, 0), ^{ if ([LGApplication canOpenURL:phoneUrl]) { [LGApplication openURL:phoneUrl]; } });}
效果
特点
- 弹出快, 有提示, 拨打完毕会跳回到拨打前App的界面
方式二
用法
/** cell的自定义代理方法 @param leaveListCell cell @param phone 电话号码 */- (void)leaveListCell:(ZDTLeaveListCell *)leaveListCell phoneCall:(NSString *)phone{ //拨打电话 NSMutableString *str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phone]; UIWebView *callWebview = [[UIWebView alloc] init]; [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]]; [self.view addSubview:callWebview];}
效果
同上
特点
弹出会有1~3s的延迟,有提示,拨打完毕会跳回到拨打前App的界面
方式三
用法
/** cell的自定义代理方法 @param leaveListCell cell @param phone 电话号码 */- (void)leaveListCell:(ZDTLeaveListCell *)leaveListCell phoneCall:(NSString *)phone{ //拨打电话 NSMutableString * phoneStr=[[NSMutableString alloc] initWithFormat:@"tel://%@",phone]; //加不加tel:后面的斜杠都一样 //NSMutableString * phoneStr=[[NSMutableString alloc] initWithFormat:@"tel:%@",phone]; NSURL *phoneUrl = [NSURL URLWithString:phoneStr]; dispatch_async(dispatch_get_global_queue(0, 0), ^{ if ([LGApplication canOpenURL:phoneUrl]) { [LGApplication openURL:phoneUrl]; } });}
效果
同上
特点
在iOS10.3上方式三和方式一是一样的.都会跳回原来的App拨打界面,亲测
结论
方式一和方式三比较好,不过考虑到可能出现的兼容问题,推荐方式一.
PS
新blog地址:www.livefor.cn
阅读全文
0 0
- iOS
- iOS
- IOS
- iOS
- iOS
- IOS
- ios
- iOS
- iOS
- IOS
- iOS
- ios
- ios ~~~~~
- ios
- IOS
- IOS
- IOS
- ios
- 深入理解Java线程池
- 【Python + selenium】在浏览器打开新页签,打开方式
- CodeForces 429B B.Working out
- kafka在zookeeper上的节点信息和查看方式
- QT 模板库、工具类和控件(三)
- iOS
- Linux 系统中用户切换
- RGB
- Android之四大组件、六大布局、五大存储
- CodeChef:Two Closest(最短路 & 思维)
- Initializing Spring root WebApplicationContext Debug Run as
- Oracle 12c 如何打开PDB可插播数据库
- nor flash函数分析
- Java必须会的Linux命令