最近在做应用内跳转到手机设置页面的时候发现了一个问题,在iOS10 以上版本的时候 跳转到定位设置页面的时候 老是跳不过去,找了好久终于找到了解决方法。废话不多说了 直接上代码
- (void)alert{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否开启定位" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 支持iOS 8 9的URL
// NSURL *preURL = [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];
// 支持iOS 8 9 10
NSURL *preurl = [NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"];
if ([[UIApplication sharedApplication] canOpenURL:preurl]){
[[UIApplication sharedApplication] openURL:preurl];
}
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:okAction];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:^{
}];
}
总结一下:
1,在iOS 8 9 上面使用"prefs:root=名称"是没有问题的 在iOS 10 以上改成了 @"App-Prefs:root=Privacy&path=名称"];
2,也是最关键的地方 在跳转到定位设置页面的 时候 在iOS 10 上面 死活 跳不过去, 后来改了一下 定位的名称可以了,只能说 好深的坑;
@"App-Prefs:root=Privacy&path=LOCATION_SERVICES"
替换成
@"App-Prefs:root=Privacy&path=LOCATION"
3,还有别忘记设置URL Scheme

OK 大功告成
以下是 一些常用的设置页面参考:
一级界面
@"App-Prefs:root=WIFI",//打开WiFi
@"App-Prefs:root=Bluetooth", //打开蓝牙设置页
@"App-Prefs:root=NOTIFICATIONS_ID",//通知设置
@"App-Prefs:root=General", //通用
@"App-Prefs:root=DISPLAY&BRIGHTNESS",//显示与亮度
@"App-Prefs:root=Wallpaper",//墙纸
@"App-Prefs:root=Sounds",//声音
@"App-Prefs:root=Privacy",//隐私
@"App-Prefs:root=STORE",//存储
@"App-Prefs:root=NOTES",//备忘录
@"App-Prefs:root=SAFARI",//Safari
@"App-Prefs:root=MUSIC",//音乐
@"App-Prefs:root=Photos",//照片与相机
@"App-Prefs:root=CASTLE"//iCloud
@"App-Prefs:root=FACETIME",//FaceTime
@"App-Prefs:root=LOCATION",//定位服务
@"App-Prefs:root=Phone",//电话
通用设置页面
@"App-Prefs:root=General&path=About",//关于本机
@"App-Prefs:root=General&path=SOFTWARE_UPDATE_LINK",//软件更新
@"App-Prefs:root=General&path=DATE_AND_TIME",//日期和时间
@"App-Prefs:root=General&path=ACCESSIBILITY",//辅助功能
@"App-Prefs:root=General&path=Keyboard",//键盘
@"App-Prefs:root=General&path=VPN",//VPN设置
@"App-Prefs:root=General&path=AUTOLOCK",//自动锁屏
@"App-Prefs:root=General&path=INTERNATIONAL",//语言与地区
@"App-Prefs:root=General&path=ManagedConfigurationList",//描述文件
隐私设置页面
@"App-Prefs:root=Privacy&path=CAMERA",//设置相机使用权限
@"App-Prefs:root=Privacy&path=PHOTOS"//设置照片使用权限
@"App-Prefs:root=Privacy&path=LOCATION"// 设置定位是否开启
网友评论