天天看點

【原】iOS學習之三種撥打電話方式的比較

撥打電話小編從網上找到三種,在這裡做一些總結和比較

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

特别注意:

  可能無法上線稽核通過

繼續閱讀