Swi*_*per 33 uiwebview ios swift3
我已经开放了webLink网址代码,Swift3但是当我使用它时,会给我这个警告;
在iOS 10.0中不推荐使用'openURL':请使用openURL:options:completionHandler:而不是
我如何解决它,我的代码如下.
let myUrl = "http://www.google.com"
if !myUrl.isEmpty {
UIApplication.shared.openURL(URL(string: "\(myUrl)")!)
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
Anb*_*hik 86
用得像
//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)
Run Code Online (Sandbox Code Playgroud)
有关更多参考,请参阅此示例链接.
Ser*_*gey 10
尝试使用此:
UIApplication.shared.open(URL(string: "\(myUrl)")!)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16884 次 |
| 最近记录: |