嗨,我无法从我的应用程序重定向到设置中的常规选项卡。在这里,我的代码请对此提供帮助
我在网址架构中添加了 prfes
guard let settingsUrl = URL(string:"prefs:root=General") else {
return
}
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: (success)") // Prints true
})
}
在iOS 10中,他们将"prefs:"更改为"App-Prefs:">
guard let profileUrl = URL(string: "App- Prefs:root=General") else { return } if UIApplication.shared.canOpenURL(profileUrl) { UIApplication.shared.open(profileUrl, completionHandler: { (success) in print(" Profile Settings opened: (success)") }) }
使用以下代码:
if let url = URL(string: UIApplicationOpenSettingsURLString) {
UIApplication.shared.open(profileUrl, completionHandler: { (success) in
print(" Profile Settings opened: (success)")
})
}
print(url)
}