【问题标题】:How to Redirect from my own app to Settings General tab in setting swift 3.0如何在设置 swift 3.0 中从我自己的应用程序重定向到设置常规选项卡
【发布时间】:2017-06-27 04:25:01
【问题描述】:

您好,我无法从我的应用重定向到设置中的“常规”选项卡。这是我的代码,请对此提供帮助

我在 url 架构中添加了 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
         })

     }

【问题讨论】:

  • UIApplication.shared.open(URL(string:"prefs:root=General&path=ManagedConfigurationList")!) 我试过了,但没用

标签: ios iphone swift3 ios10


【解决方案1】:

使用以下代码:

if let url = URL(string: UIApplicationOpenSettingsURLString) {
    UIApplication.shared.open(profileUrl, completionHandler: { (success) in
            print(" Profile Settings opened: \(success)")
        })
    }
    print(url)
}

【讨论】:

  • 嗨,Hiren,感谢您的回复。我能够导航到应用程序设置,但我希望它直接导航到设置中的常规选项卡。您的回答只能重定向到应用设置
  • UIApplication.shared.open(URL(string:"prefs:root=General&path=ManagedConfigurationList")!) 我试过了,但没用
  • 使用这个可能会失败:UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=General")!)
【解决方案2】:

在 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)")

            })
         }

【讨论】:

  • 不要使用这个.. 使用 Prefs/App-Pref 属于苹果的私有 API。他们以同样的理由拒绝了我们的应用。
猜你喜欢
  • 2015-05-19
  • 2012-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多