I have a UIAlertController with one Button named "Settings". With a tap on that i want to go to a specific section (eg Bluetooth) within the settings App. I saw many solutions here, but they all does not work for iOS 11.
Here is my Code:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(_ animated: Bool) {
let alertView = UIAlertController(title: "Info", message: "message", preferredStyle: .alert)
alertView.addAction(UIAlertAction(title: "Settings", style: .cancel, handler: { (alert) in
UIApplication.shared.open(URL(string:"App-Prefs:root=Settings&path=General")!, options: [:], completionHandler: nil)
}))
self.present(alertView, animated: true, completion: nil)
}
}
I also added under App->Target->Info->URLTypes->URL Schemes: "App-Prefs". I also tried "prefs" But nothing is working.
Does anyone have a solution for iOS 11? Any help is highly appreciated
You just try UIApplicationOpenSettingsURLString
without App-Prefs
if let url = URL(string:UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
let url = UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.