我编写了一些代码来启动来自String的电话呼叫,如附加的图像。 [功能:phoneCallInitiation] [1]ios 10在某些号码上没有启动Swift电话
某些电话号码可以很好地发起与格式,如02-123-1234,但一些电话号码031-123-1234不能启动,但我可以看到phoneNumberString是运作良好。
你能猜出任何理由来这样工作吗?
func callButtonPressed() {
let alertViewController = UIAlertController(title: NSLocalizedString("Call", comment: ""), message: "\(storeToDisplay.phoneNumber!)", preferredStyle: .alert)
alertViewController.addAction(UIAlertAction(title: "Call", style: .default, handler: { (alertAction) -> Void in
let phoneNumberString = "tel://\(self.storeToDisplay.phoneNumber!)"
print("This is phonenumber: \(phoneNumberString)")
if let url = URL(string: phoneNumberString) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
print("WHAT Happenes")
}
}))
alertViewController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (alertAction) -> Void in
alertViewController.dismiss(animated: true, completion: nil)
}))
present(alertViewController, animated: true, completion: nil)
}
删除'-',并尝试一次 –
我也试着删除' - '在电话号码中间,但结果仍然是一样的。无法拨打电话 –