拨打电话小编从网上找到三种,在这里做一些总结和比较
1、基本使用
NSString *str = [[NSMutableString alloc] initWithFormat:@"tel://%@",@"152xxxx4165"]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
这种方法,拨打完电话回不到原来的应用,会停留在通讯录里,而且是直接拨打,不弹出提示!
在iOS9.0之后,这个方法也是可以回到原来的应用
2、推荐使用
UIWebView *webView = [[UIWebView alloc]init]; NSURL *url = [NSURL URLWithString:@"tel://152*****4165"]; [webView loadRequest:[NSURLRequest requestWithURL:url]]; [self.view addSubview:webView];
这种方法,打完电话后还会回到原来的程序,也会弹出提示!
3、不建议使用,做了解就可以
NSString *str = [[NSMutableString alloc] initWithFormat:@"telprompt://%@",@"152xxxx4165"]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str
注意该方法与方法1的区别是:所拼接的字符串是 telprompt,而不是 tel
特别注意:
可能无法上线审核通过
本文介绍了三种在iOS中实现拨打电话的方法,并进行了对比分析。第一种方法直接调用,但存在返回应用的问题;第二种方法使用UIWebView加载tel URL,可正常返回应用且有提示;第三种方法使用telprompt URL,但可能影响应用审核。
629

被折叠的 条评论
为什么被折叠?



