更新到iOS 14后,如果将浏览器从默认Safari更改为Chrome,则无法在浏览器中打开网址。
我做了一些调查,发现UIApplication.shared.canOpenURL(url)
总是返回false。
请帮忙。
对于iOS 14+
我建议将此添加到您的Info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
</array>
通过添加此内容,您可以继续使用方法 canOpenURL(_ url: URL) -> Bool
guard let url = URL(string: "https://example.com") else { return }
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句