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]];
总结
以上所述是小编给大家介绍的ios拨打电话的3种实现方式 ,希望对大家有所帮助
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论