如何打开iOS8的设备设置?

时间:2018-10-18 09:50:55

标签: ios swift3 settings

我一直看到您可以使用

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

,但仅适用于iOS 10及更高版本。但是,对于iOS 8,我该怎么做?

3 个答案:

答案 0 :(得分:0)

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)")
    })
}

答案 1 :(得分:0)

目前,我几乎看不到任何对iOS 8的应用程序支持。但是,如果您想知道,这里是答案:

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

答案 2 :(得分:0)

这是对我有用的

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