问题
I've made a simple test application that open the Settings app programmatically, by a specific button. Instead of opening the desired settings page (the wifi page, in this case) it opens the generic setting screen. Could someone please help me understanding what exactly changed in Swift 4, in order for me to fix this behavior? Thansk a lot!
This code:
if let url = URL(string:"App-Prefs:root=WIFI") {
if UIApplication.shared.canOpenURL(url) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
回答1:
This is not a Swift 4 issue. Apple changes the Settings app urls very often. While some older versions of the Settings app support App-Prefs:root=WIFI
, the Settings app in iOS 11 does not support it.
来源:https://stackoverflow.com/questions/48533748/swift-4-ios-11-apps-prefs-root-function-not-working