IOS 11 /“Apps-prefs = root”更新到Swift 3后,函数无法正常工作 [英] IOS 11 / "Apps-prefs=root" function not working after update to Swift 3

查看:119
本文介绍了IOS 11 /“Apps-prefs = root”更新到Swift 3后,函数无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Swift编程很陌生
我做了一个简单的测试应用程序,通过一个特定的按钮以编程方式打开设置。

I'm quite new to Swift programming I've made a simple test application that open the settings programmatically, by a specific button.

不幸的是更新按钮后,而不是打开所需的设置页面(在这种情况下为wifi页面)只打开通用设置屏幕
有人可以帮我理解swift 4中究竟发生了什么变化,为了我修复此行为? Thansk很多!

Unfortunately after the update the button, instead of opening the desired setting page (the wifi page, in this case) open only the generic setting screen Could someone please help me understanding what exactly changed in swift 4, in order for me to fix this behaviour? Thansk a lot!

使用的第一个代码 - (我已经将iOS改为iOS 11.0,以便与部署相匹配)

First code used - (i've either changed the iOS available to iOS 11.0, in order to match the deployment)

if let url = URL(string:"App-Prefs:root=WIFI") {
            if UIApplication.shared.canOpenURL(url) {
                if #available(iOS 10.0, *) {
                    UIApplication.shared.open(url, options: [:], completionHandler: nil)
                } else {
                    UIApplication.shared.openURL(url)
                }
            }
        }

使用的第二个代码

let url = URL(string: "App-Prefs:root=WIFI") 
UIApplication.shared.openURL(url!)

编辑

不幸的是,提出的问题与我的不同 - 我不能再打开设备的设置,另一个问题是如何直接打开APP的设置

Unfortunately the question raised is different from mine - i cannot anymore open the settings of the device, the other question ask how to open directly the settings of the APP

推荐答案

在App Store中禁止使用 App-Prefs:root 等网址并使用它应用拒绝。

Urls like App-Prefs:root are prohibited in App Store and using it causing app rejection.

如果您想要打开应用首选项,可以使用 UIApplicationOpenSettingsURLString

If you want open app preferences you could use UIApplicationOpenSettingsURLString

这篇关于IOS 11 /“Apps-prefs = root”更新到Swift 3后,函数无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆