[英]iOS canOpenURL fails for phone dialing
尝试尝试,可能我无法获得一个简单的应用程序来拨打号码。
我在此功能上添加了一个按钮动作:
@IBAction func wackAMole(sender: AnyObject) {
var phoneNumber = "tel://555-555-5555"
var url = NSURL(fileURLWithPath: phoneNumber)
var sharedApplication = UIApplication.sharedApplication()
if (sharedApplication.canOpenURL(url)) {
sharedApplication.openURL(url)
}
}
我还向“ Info.plist”添加了“电话”作为“必需的设备功能”,但仍然无济于事。 在iPhone 5上的调试器下运行时,canOpenURL()返回false。
即使我将phoneNumber更改为“ https://google.com ”,canOpenURL()也会返回false。
有什么想法下一步去看吗?
您不会为本地文件系统条目创建URL,因此您不应使用fileURLwithPath
。 您应该使用URLWithString
var url = NSURL.URLWithString(phoneNumber)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.