问题
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.
回答1:
As of iOS 8, it's possible to launch the Settings app that directly opens your Privacy app section in this way:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
In Swift:
if let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString) {
UIApplication.sharedApplication().openURL(settingsURL)
}
In Swift 3.0:
if let settingsURL = URL(string: UIApplicationOpenSettingsURLString + Bundle.main.bundleIdentifier!) {
UIApplication.shared.openURL(settingsURL as URL)
}
回答2:
1.- Add URL Types
2.- Use:
Objective - 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:
This is not possible anymore in iOS 11, we can just open Settings. Here a Swift 4 code snippet:
if let url = URL(string:UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
回答4:
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.
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?
Opening the Settings app from another app
来源:https://stackoverflow.com/questions/25988241/url-scheme-open-settings-ios