首页 文章

在ios 8,9和10中重定向到设置根页面

提问于
浏览
4

我的问题已被问了很多时间,直到现在还没有解决方案 . 我正在尝试从应用程序打开移动数据页面 .

1)我试过了

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]

iOS 8 and iOS 9 中,而不是 root page ,它直接转到 Settings/AppName 页面 . 这不是我想要的行为 . 我想要的是进入设置根页面

2)至于 iOS 10 ,上述方法并没有尝试过

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil]

但它不起作用 .

是否有任何代码可以满足上述两个要求 . 在 iOS 8,9和10中,它将转到设置根页面(如果可能,移动数据页面) . 如果没有't any way, can provide link why it doesn'工作 .

UPDATE:

在ios 8和9中,通过使用[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@“prefs:root = GENERAL”]]我可以重定向到设置主页 .

对于ios 10.1.0及更低版本,使用[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@“prefs:root = MOBILE_DATA”]]将重定向到“设置”中的应用程序特定页面 . 但在最新的10.1.1中,它不会做任何事情 .

我正在使用Xcode 8.0 .

2 回答

  • 0

    在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)")
    
            })
         }
    
  • 1

    url types

    UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root=General")!)
    

    其他路径:iOS Launching Settings -> Restrictions URL Scheme

相关问题