从另一个应用程序以编程方式在iOS的设置应用程序中打开键盘的设置屏幕 [英] Open Keyboard's settings screen in iOS's settings app programmatically from another app

查看:156
本文介绍了从另一个应用程序以编程方式在iOS的设置应用程序中打开键盘的设置屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何以编程方式直接进入iOS设置应用程序的任何下面提到的屏幕

How can we go directly to any of the below mentioned screens of iOS's settings app programmatically


< a href =https://i.stack.imgur.com/MXlfh.png =nofollow noreferrer>

推荐答案

更新

正如其他用户指出的那样,这个解决方案不再适用于iOS10。如果有人知道如何让它在iOS10中运行,请告诉我们。

As other users have pointed out this solution does not work anymore with iOS10. If anyone has an idea how to make it work in iOS10, please let us know.

iOS解决方案< 10:

要打开(您自己的应用程序)的设置,您可以使用 UIApplicationOpenSettingsURLString 常量:

To open the settings (of your own app) you can use the UIApplicationOpenSettingsURLString constant:

if let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString) {
    UIApplication.sharedApplication().openURL(settingsURL)
}

这是在iOS 8中引入的,因此您可以在运行的设备上使用它iOS8或更高版本。但这只会打开您自己的应用程序的设置。不是键盘设置。如果您的应用没有自己的设置,则只会在其主页上打开设置应用。

This was introduced in iOS 8, so you can use it on devices that run iOS8 or later. But this only opens the settings of your own app. Not the keyboard settings. And if your app does not have its own settings it only opens the Settings app on its main page.

在过去(iOS 5.1之前),您可以打开设置URL并直接转到设置应用中的几乎任何子页面。 Apple在iOS 5.1中删除了此功能。

In the old days (before iOS 5.1) you could open a settings URL and directly go to almost any subpage in the Settings app. Apple removed this feature in iOS 5.1.

然而它似乎在iOS 8和9中再次运行。它没有被Apple正式记录,但似乎有效,但我不确定这是多么可靠。它适用于我的iOS 9.1 iPhone,但不适用于模拟器。

However it seems to work again in iOS 8 and 9. It is not officially documented by Apple but it seems to work, although I not sure how reliable this is. It works on my iOS 9.1 iPhone but not in the Simulator.

因此,请谨慎使用此功能打开键盘设置:

So, with caution, you can try this to open the Keyboard Settings:

if let settingsURL = NSURL(string: "prefs:root=General&path=Keyboard") {
    UIApplication.sharedApplication().openURL(settingsURL)
}

或者更深入:

if let settingsURL = NSURL(string: "prefs:root=General&path=Keyboard/KEYBOARDS") {
    UIApplication.sharedApplication().openURL(settingsURL)
}

修改:
正如iHulk在评论中提到的,您可能需要添加 prefs 到项目的Info.plist文件中的URL方案,以使其工作。

As iHulk mentioned in the comments you might have to add prefs to the URL schemes in your project's Info.plist file to make this work.

这篇关于从另一个应用程序以编程方式在iOS的设置应用程序中打开键盘的设置屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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