在iOS9中以编程方式打开手机设置 [英] Open phone settings programmatically in iOS9
问题描述
我最近有一个应用程序登陆应用程序商店,他们拒绝批准我使用的以下代码手机设置:
I recently have an app summited to the app store and they refused to approve the following code I used open phone settings:
let url:NSURL! = NSURL(string : "prefs:root=")
UIApplication.sharedApplication().openURL(url)
所以我得到了以下代码(如何在点击按钮时打开手机设置并获得批准:
So I got the following code (How do i open phone settings when a button is clicked ios) and got it approved:
UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)
不幸的是它不做我真正需要的是,它有时会打开我的应用程序设置,有时会打开手机设置。
Unfortunately it does not do what I really need as it opens my application settings sometimes and other times it opens the phone settings.
我需要打开一些东西 just&只改为 手机设置。
And I need something to open just & only the phone settings instead.
推荐答案
在iOS 10中,prefs必须替换为App-Prefs。
然后您可以使用此代码测试所有可能的网址。
In iOS 10, "prefs" must be replaced with "App-Prefs". You can then use this code which tests over all the possible urls.
NSArray* urlStrings = @[@"prefs:root=<your_path>", @"App-Prefs:root=<your_path>"];
for(NSString* urlString in urlStrings){
NSURL* url = [NSURL URLWithString:urlString];
if([[UIApplication sharedApplication] canOpenURL:url]){
[[UIApplication sharedApplication] openURL:url];
break;
}
}
这篇关于在iOS9中以编程方式打开手机设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!