在 iOS 10 中,请勿打开设置网址:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
有什么问题?
答案 0 :(得分:12)
我确实喜欢这样,而且很有效。我今天正在测试它!
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
斯威夫特3:
let urlObj = NSURL.init(string:UIApplicationOpenSettingsURLString)
if #available(iOS 10.0, *) {
UIApplication.shared.open(urlObj as! URL, options: [ : ], completionHandler: { Success in
})
} else {
let success = UIApplication.shared.openURL(url as URL)
print("Open \(url): \(success)")
}
答案 1 :(得分:2)
雨燕4
if let url = URL(string: UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
_ = UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
答案 2 :(得分:0)
对于iOS 11 +
UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[application openURL:URL options:@{} completionHandler:^(BOOL success) {
if (success) {
NSLog(@"Opened url");
}
}];
答案 3 :(得分:0)
Apple Swift 5.3 版:
if let url = URL(string: UIApplication.openSettingsURLString), UIApplication.shared.canOpenURL(url){
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}