URL Scheme“打开设置”ios

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25988241/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:43:17  来源:igfitidea点击:

URL Scheme "Open Settings" ios

iosxcodeios7ios8url-scheme

提问by MaappeaL

I know this question has been asked so many times. The answers say that this is not available in Xcode > 5.x. but I saw some apps that can use this(Go to Settings)(iOS7). Is there any way to do this? Is it available in Xcode 6? Facebook can detect both cellular data and wifi.

我知道这个问题已经被问过很多次了。答案说这在 Xcode > 5.x 中不可用。但我看到一些可以使用它的应用程序(转到设置)(iOS7)。有没有办法做到这一点?它在 Xcode 6 中可用吗?Facebook可以检测蜂窝数据和 wifi

enter image description hereenter image description here

在此处输入图片说明在此处输入图片说明

回答by BalestraPatrick

As of iOS 8, it's possible to launch the Settings app that directly opens your Privacy app section in this way:

从 iOS 8 开始,可以通过以下方式启动直接打开您的隐私应用程序部分的设置应用程序:

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

In Swift:

在斯威夫特:

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

In Swift 3.0:

在 Swift 3.0 中:

if let settingsURL = URL(string: UIApplicationOpenSettingsURLString + Bundle.main.bundleIdentifier!) {
    UIApplication.shared.openURL(settingsURL as URL)
}

回答by Pablo

1.- Add URL Types enter image description here

1.- 添加 URL 类型 在此处输入图片说明

2.- Use:

2.- 使用:

Objective - C

目标-C

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]];

Swift

迅速

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

3.- Other path find in this answer: iOS Launching Settings -> Restrictions URL Scheme

3.- 在此答案中找到其他路径:iOS Launching Settings -> Restrictions URL Scheme

回答by chawki

This is not possible anymore in iOS 11, we can just open Settings. Here a Swift 4 code snippet:

这在 iOS 11 中不再可能,我们可以打开设置。这是一个 Swift 4 代码片段:

if let url = URL(string:UIApplicationOpenSettingsURLString) {
   if UIApplication.shared.canOpenURL(url) {
     UIApplication.shared.open(url, options: [:], completionHandler: nil)
   }
}

回答by user3069232

iOS 13, Swift 5.0

iOS 13,斯威夫特 5.0

Syntax for open settings changed [again] a tiny bit.

打开设置的语法 [再次] 稍微改变了一点。

if let url = URL(string:UIApplication.openSettingsURLString) {
     if UIApplication.shared.canOpenURL(url) {
       UIApplication.shared.open(url, options: [:], completionHandler: nil)
     }
  }

回答by pawel_d

Alerts on your screenshots are system alerts. The first occurs when app wants to use internet and have a blocked cellular data for application (and Wifi is not connected). The second occurs when an application wants to use location services, and you have turned off wifi. It is not possible control the display of these alerts.

屏幕截图上的警报是系统警报。第一种发生在应用程序想要使用互联网并阻止应用程序的蜂窝数据(并且未连接 Wifi)时。第二种情况发生在应用程序想要使用定位服务而您已关闭 wifi 时。 无法控制这些警报显示

In iOS 8 (Xcode 6) is the ability to open the settings directly from the application. Please read this topics: How to open Settings programmatically like in Facebook app?

在 iOS 8 (Xcode 6) 中,可以直接从应用程序打开设置。请阅读以下主题: 如何像在 Facebook 应用中一样以编程方式打开设置?

Opening the Settings app from another app

从另一个应用程序打开设置应用程序