在iOS10以后直接使用以下方法,会存在延迟
UIApplication.shared.openURL(NSURL(string :"tel://"+phone)! as URL)
解决方法
/// 拨打电话
func hw_callPhone(_ phone: String) {
if phone.isEmpty {
print("电话号码异常")
} else {
if #available(iOS 10.0, *) {
UIApplication.shared.open(NSURL(string :"tel://"+phone)! as URL, options: ["":""], completionHandler: { (tag) in })
} else {
UIApplication.shared.openURL(NSURL(string :"tel://"+phone)! as URL)
}
}
}
网友评论