gpt4 book ai didi

iOS canOpenURL 电话拨号失败

转载 作者:行者123 更新时间:2023-11-28 11:22:41 25 4
gpt4 key购买 nike

尽我所能,我无法获得一个简单的应用程序来拨号。

我将一个按钮操作挂接到此函数:

@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)

关于iOS canOpenURL 电话拨号失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26080083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com