【问题标题】:How to open device setting for iOS8?如何打开 iOS8 的设备设置?
【发布时间】:2019-03-23 02:36:08
【问题描述】:

我一直看到你可以使用

if UIApplication.shared.canOpenURL(settingsUrl) {
    UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
        print("Settings opened: \(success)")
    })
}

但它仅适用于 iOS 10 及更高版本。但是我怎样才能为 iOS 8 做同样的事情呢?

【问题讨论】:

标签: ios swift3 settings


【解决方案1】:

这对我有用

if UIApplication.openSettingsURLString != nil{
    if let aString = URL(string: UIApplication.openSettingsURLString){
        UIApplication.shared.openURL(aString)
    }
}

【讨论】:

    【解决方案2】:

    UIApplication.openSettingsURLString 将返回设置 url 字符串。

    if let settingsURL = URL(string: UIApplication.openSettingsURLString),
        UIApplication.shared.canOpenURL(settingsURL) {
        UIApplication.shared.open(settingsURL, completionHandler: { (success) in
            print("Settings opened: \(success)")
        })
    }
    

    【讨论】:

    • open(_:options:completionHandler:) 仅适用于 iOS 10.0 或更新版本
    【解决方案3】:

    目前,我很少再看到任何应用程序支持 iOS 8。但如果你想知道,这里有答案:

    let urlStr = "yourURL"
    if let linkURL = URL(string: urlString), UIApplication.shared.openURL(URL) {
     UIApplication.shared.openURL(linkURL)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-23
      • 2020-07-04
      • 1970-01-01
      • 2014-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多