Vin*_*ent 7 url-scheme swift ios11
我想在 iOS 11 中使用 Swift 4 在设置应用程序中打开我的应用程序的设置页面。就像图片所示:
以下代码不起作用,它只会打开设置应用程序:
if let url = URL(string:UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
上图中显示的应用程序能够做到这一点。所以我想知道是否有任何方法可以自定义 URL Scheme 来实现它?
糟糕,它似乎适用于 iOS 11.4.1:
if let url = URL(string:UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
只是更新,因为 UIApplicationOpenSettingsURLString 发生了变化。
guard let url = URL(string: UIApplication.openSettingsURLString) else {
return
}
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:])
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4677 次 |
| 最近记录: |