【发布时间】:2019-09-04 12:30:00
【问题描述】:
我需要在 Safari 浏览器中打开一个链接,但我有疑问,我应该使用哪种方法? openURL/open 或 canOpenURL。
谁能帮我解释这两个功能之间的实际区别?
if #available(iOS 10.0, *) {
UIApplication.shared.open(URL(string: urlStr)!, options: [:], completionHandler: nil)
UIApplication.shared.canOpenURL(URL(string: urlStr)!)
} else {
UIApplication.shared.openURL(URL(string: urlStr)!) //introduced: 2.0, deprecated: 10.0,
UIApplication.shared.canOpenURL(URL(string: urlStr)!) // available(iOS 3.0, *)
}
【问题讨论】:
-
你用的是哪个版本的Xcode和swift?
-
xcode 9.2 (swift 4)