在iOS 10.0中不建议使用'openURL':请在Swift 3中使用openURL:options:completionHandler: [英] 'openURL' was deprecated in iOS 10.0: Please use openURL:options:completionHandler: instead in Swift 3
本文介绍了在iOS 10.0中不建议使用'openURL':请在Swift 3中使用openURL:options:completionHandler:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Swift3
中有可用的开放式WebLink网址代码,但使用时会出现此警告;
I have working open webLink url codes in Swift3
but when I use it gives me this warning;
在iOS 10.0中不建议使用'openURL':请改用openURL:options:completionHandler:
'openURL' was deprecated in iOS 10.0: Please use openURL:options:completionHandler: instead
如何解决它,我的代码在下面.
How can I resolve it, my codes under below.
let myUrl = "http://www.google.com"
if !myUrl.isEmpty {
UIApplication.shared.openURL(URL(string: "\(myUrl)")!)
}
谢谢.
推荐答案
使用方式
//inside scope use this
let myUrl = "http://www.google.com"
if let url = URL(string: "\(myUrl)"), !url.absoluteString.isEmpty {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
// or outside scope use this
guard let url = URL(string: "\(myUrl)"), !url.absoluteString.isEmpty else {
return
}
UIApplication.shared.open(url, options: [:], completionHandler: nil)
有关更多参考,请参见此示例链接.
For more reference see this sample link.
这篇关于在iOS 10.0中不建议使用'openURL':请在Swift 3中使用openURL:options:completionHandler:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文