【问题标题】:Open iOS Settings App in Specific Section在特定部分打开 iOS 设置应用程序
【发布时间】:2015-12-06 04:03:20
【问题描述】:

我知道这一点

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

这会打开设置应用程序并直接将您带到与您的应用程序相关的设置。但我想转到“设置”应用程序中的特定部分。就我而言,我特别想打开设置 -> 隐私 -> 位置服务。我怎样才能做到这一点?

【问题讨论】:

    标签: ios cllocationmanager


    【解决方案1】:

    您必须采取三个单独的步骤才能让您的应用在“设置”中打开特定部分。

    首先,打开项目目标的Info 部分。然后展开底部的 URLTypes 部分。将prefs 添加到 URL 方案文本框

    接下来,将此代码放入您希望打开“设置”特定部分的应用中。

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"prefs:root=General&path=About"]]
    

    最后,更改 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`
    

    看起来prefs:root=LOCATION_SERVICES 是您想要的。另外,这仅适用于 iOS 8 及更高版本。

    编辑添加:此信息不是官方信息,Apple 在其文档中不支持。此代码可能会在未来的 iOS 版本中中断,并可能导致 App Store 审核出现问题。

    【讨论】:

    • 你能分享一下官方记录的地方吗?
    • 实际上,我是从 SO 上的各个地方提取的。但是您可能会在这些 Apple 开发者论坛 (forums.developer.apple.com/thread/21886 & forums.developer.apple.com/message/65964#65964) 中查看这两个条目——尽管它在测试中运行良好,但尚不清楚使用 prefs 方案是否会通过审核。跨度>
    • 您应该明确表示这不是官方的,不受支持,可能会在未来的 iOS 版本中中断(就像过去一样),并且可能会导致 App Store 审核出现问题。
    • 谢谢,@jcaron 你是对的——我已经在我的回答中添加了那个注释。
    • 我刚刚向 Apple 提交了一份增强请求,要求将非官方的“prefs”方案正式化。我会在这里发布他们的回复。
    【解决方案2】:

    GlennRay 的回答在实施中是正确的,但只是为了添加更多信息。

    https://developer.apple.com/library/content/qa/qa1924/_index.html

    Apple 明确声明仅支持键盘设置,所有其他打开特定部分的值都违反了 App Review 指南。

    【讨论】:

      猜你喜欢
      • 2012-11-03
      • 1970-01-01
      • 2017-08-23
      • 1970-01-01
      • 2019-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-03
      相关资源
      最近更新 更多