似乎Apple已经将很多应用程序配置移动到iOS 11的App路径,如何在设置中以编程方式打开应用程序路径?我试过,"App-Prefs:root=\(Bundle.main.bundleIdentifier!)"但这似乎不起作用.
请注意,我的问题特定于:如何在设置中打开应用程序路径:不知道如何打开设置
Dam*_*rot 44
以下是您正在寻找的代码,我想:
if let url = URL(string: UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
Ale*_*cci 14
Swift 4.2,iOS 12
使用以下功能可以打开设置:
extension UIApplication {
...
@discardableResult
static func openAppSettings() -> Bool {
guard
let settingsURL = URL(string: UIApplication.openSettingsURLString),
UIApplication.shared.canOpenURL(settingsURL)
else {
return false
}
UIApplication.shared.open(settingsURL)
return true
}
}
Run Code Online (Sandbox Code Playgroud)
用法: UIApplication.openAppSettings()
但请注意不要使用" 非公共URL方案 ",例如:prefs:root=或者App-Prefs:root,否则您的应用将被拒绝.这件事最近发生在我身上,因为我试图在设置中与wifi部分建立深层链接.
| 归档时间: |
|
| 查看次数: |
14813 次 |
| 最近记录: |