iOS----------撥打電話的3種方式


iOS實現撥打電話的方式:
 
方法一、requestWithURL,此方法撥打前彈出提示

 

NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"tel:%@",@"136****0000"];
UIWebView * callWebview = [[UIWebView alloc] init];
[callWebview loadRequest:[ NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
[ self.view addSubview:callWebview];
 

 

swift代碼:

let callWebview =   UIWebView()callWebview.loadRequest(NSURLRequest(url: URL(string: "tel:136****0000")!) as URLRequest)
self.view.addSubview(callWebview)

 

 

 

 

方法二、openURL(telprompt) ,此方法撥打前彈出提示,據說會導致App Store審核不通過

NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"telprompt:%@",@"136****0000"];
[[ UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
 

 

swift代碼:

 

方法三、利用openURL(tel),此方法在iOS 10.2之前不會添加彈框,需要自己處理,手動添加alert即可

NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"tel:%@",@"136****0000"];
[[ UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];

swift代碼:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM