iOS 三种拨打电话的代码
这三种代码 都是会有提示的
1 使用UIWebView 拨打电话
NSString * telStr = [NSString stringWithFormat:@"tel:010-xxxx-xxxx ] ;
UIWebView * webView = [[UIWebView alloc] init ] ;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:telStr]]];
[self.view addSubView: webView ] ;
2 使用 UIApplication 的 openURL 方法
NSString * telStr = [NSString stringWithFormat:@"tel:010-xxxx-xxxx ] ;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: telStr] options:@{} completionHandler:nil ] ;
3 使用UIApplication 的 openURL方法,只不过是将 tel 换成 telprompt 。
NSString * telprompt = @"telprompt://010-xxxx-xxxx" ;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: telprompt] options:@{} completionHandler:nil ] ;
本文介绍了在iOS中实现拨打电话功能的三种方法:通过UIWebView加载tel链接、使用UIApplication的openURL方法直接调用电话应用及使用telprompt自定义方案。这三种方法均会在拨打前提示用户。
294

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



