作者:奥咨达医疗器_械丶服务集团 | 来源:互联网 | 2023-01-16 17:42
似乎Apple已经将很多应用程序配置移动到iOS 11的App路径,如何在设置中以编程方式打开应用程序路径?我试过,"App-Prefs:root=\(Bundle.main.bundleIdentifier!)"
但这似乎不起作用.
请注意,我的问题特定于:如何在设置中打开应用程序路径:不知道如何打开设置
Damien Banne..
44
以下是您正在寻找的代码,我想:
if let url = URL(string: UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
Alessandro F..
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
}
}
用法: UIApplication.openAppSettings()
但请注意不要使用" 非公共URL方案 ",例如:prefs:root=
或者App-Prefs:root
,否则您的应用将被拒绝.这件事最近发生在我身上,因为我试图在设置中与wifi部分建立深层链接.
1> Damien Banne..:
以下是您正在寻找的代码,我想:
if let url = URL(string: UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
2> Alessandro F..:
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
}
}
用法: UIApplication.openAppSettings()
但请注意不要使用" 非公共URL方案 ",例如:prefs:root=
或者App-Prefs:root
,否则您的应用将被拒绝.这件事最近发生在我身上,因为我试图在设置中与wifi部分建立深层链接.
您应该将`UIApplication.openAppSettings()`命名为(注意`s`)以符合`openSettingsURLString`