我有正在使用的开放式WebLink网址代码,Swift3
但是在使用它时会出现此警告。
iOS 10.0中不推荐使用'openURL':请改用openURL:options:completionHandler:
我如何解决它,下面的代码。
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)
有关更多参考,请参见此示例链接。
尝试使用此:
UIApplication.shared.open(URL(string: "\(myUrl)")!)
本文地址:http://ios.askforanswer.com/zaiios-10-0zhongbujianyishiyongopenurlqingzaiswift-3zhongshiyongopenurloptionscompletionhandl.html
文章标签:ios , swift3 , uiwebview
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!
文章标签:ios , swift3 , uiwebview
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!
评论已关闭!