[英]Open iOS Settings App in Specific Section
I am aware of this 我知道这个
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
which opens Settings App and takes you directly to the settings related to YOUR app. 这会打开“设置”应用,并直接将您带到与您的应用相关的设置。 But I would like to go to a specific section in the Settings app.
但我想转到“设置”应用中的特定部分。 For my case, I specifically would like to open Settings -> Privacy -> Location Services.
就我而言,我特别想打开设置->隐私->位置服务。 How can I achieve this?
我该如何实现?
You have to take three separate steps to allow your app to open specific sections in Settings. 您必须采取三个单独的步骤,以允许您的应用打开“设置”中的特定部分。
First, open up the Info
section of a project's target. 首先,打开项目目标的“
Info
部分。 Then expand the URLTypes section at the bottom. 然后,展开底部的URLTypes部分。 Add
prefs
to the URL Schemes textbox 将
prefs
添加到“ URL方案”文本框中
Next, put this code in your app where you want the specific section of Settings to open. 接下来,将此代码放在您要打开“设置”特定部分的应用中。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"prefs:root=General&path=About"]]
Finally, change the text in the URL string to indicate the section you want -- here's the list of possibilities: 最后,更改URL字符串中的文本以指示所需的部分-这是可能性的列表:
prefs:root=General&path=About
prefs:root=General&path=ACCESSIBILITY
prefs:root=AIRPLANE_MODE
prefs:root=General&path=AUTOLOCK
prefs:root=General&path=USAGE/CELLULAR_USAGE
prefs:root=Brightness
prefs:root=General&path=Bluetooth
prefs:root=General&path=DATE_AND_TIME
prefs:root=FACETIME
prefs:root=General
prefs:root=General&path=Keyboard
prefs:root=General&path=INTERNATIONAL
prefs:root=LOCATION_SERVICES
prefs:root=ACCOUNT_SETTINGS
prefs:root=MUSIC
prefs:root=MUSIC&path=EQ
prefs:root=MUSIC&path=VolumeLimit
prefs:root=General&path=Network
prefs:root=NIKE_PLUS_IPOD
prefs:root=NOTES
prefs:root=NOTIFICATIONS_ID
prefs:root=Phone
prefs:root=Photos
prefs:root=General&path=ManagedConfigurationList
prefs:root=General&path=Reset
prefs:root=Sounds&path=Ringtone
prefs:root=Safari
prefs:root=General&path=Assistant
prefs:root=Sounds
prefs:root=General&path=SOFTWARE_UPDATE_LINK
prefs:root=STORE
prefs:root=TWITTER
prefs:root=FACEBOOK
prefs:root=General&path=USAGE prefs:root=VIDEO
prefs:root=General&path=Network/VPN
prefs:root=Wallpaper
prefs:root=WIFI
prefs:root=INTERNET_TETHERING`
It looks like prefs:root=LOCATION_SERVICES
is the one you'd want. 看起来像是
prefs:root=LOCATION_SERVICES
是您想要的那个。 Plus, this will only work for iOS 8 and higher. 另外,这仅适用于iOS 8及更高版本。
Edited to Add: This information is not official and is not supported by Apple in their documentation. 编辑添加: 此信息不是官方的,Apple的文档也不支持此信息。 This code may break in future iOS releases and may cause issues with App Store review.
此代码可能会在将来的iOS版本中中断,并可能导致App Store审核出现问题。
GlennRay's answer is correct in implementation but just to add a little more info. GlennRay的答案在实现上是正确的,只是增加了一些信息。
https://developer.apple.com/library/content/qa/qa1924/_index.html https://developer.apple.com/library/content/qa/qa1924/_index.html
Apple specifically state that only the keyboard settings is supported and all other values to open to a specific section are a violation of the App Review guidelines. Apple特别声明仅支持键盘设置,而所有其他要打开到特定部分的值均违反了App Review指南。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.