我想打电话,这是我的代码:
if let urlMobile = NSURL(string: "tel://076938483"), UIApplication.shared.canOpenURL(urlMobile as URL) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(urlMobile as URL, options: [:], completionHandler: nil)
}
else {
UIApplication.shared.openURL(urlMobile as URL)
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用swift 3这样做,但我收到此错误:
-canOpenURL: failed for URL: "tel://09178883828" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
Run Code Online (Sandbox Code Playgroud)
有没有想过这样做?
某些 LSApplicationQueriesScheme 不适用于模拟器。错误代码 -10814 适用于 kLSApplicationNotFoundErr。模拟器无法启动电话拨号盘。所以在 iPhone 设备上运行它。
这对我有用!
代码应该是
if let url = NSURL(string: "tel://\(yourNumber)"), UIApplication.shared.canOpenURL(url as URL) {
UIApplication.shared.open(url as URL, options: [:], completionHandler: nil)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1675 次 |
| 最近记录: |