iOS开发中拨打电话的方法

2016-09-30  本文已影响94人  多啦A梦的百宝袋

1,这种方法,拨打完电话回不到原来的应用,会停留在通讯录里,而且是直接拨打,不弹出提示

NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"186xxxx6979"];
    //            NSLog(@"str======%@",str);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    ````
2,创建一个UIWebView来加载URL,拨完后能自动回到原应用(推荐)

UIWebView *webView = [[UIWebView alloc]init];
NSMutableString *str = [[NSMutableString alloc]initWithFormat:@"telprompt://%@",_serviceModel.phone];
NSURL *url = [NSURL URLWithString:str];
[webView loadRequest:[NSURLRequest requestWithURL:url]];
[self.view addSubview:webView];

3,这种方法也会回去到原来的程序里(注意这里的telprompt),也会弹出提示。
私有API,因此可能通不过苹果官方审核。

NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",@"186xxxx6979"];
// NSLog(@"str======%@",str);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]

上一篇下一篇

猜你喜欢

热点阅读