有时候,因为权限等问题,我们需要让用户可以在APP内直接通过点击确认跳转到系统设置中的某个条目或者当前APP设置信息去修改一些内容。
iOS8以下开放了这个语句用于跳转:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
这个语句iOS10以上也是适用的,可惜只能跳到设置界面,而不能进入详细的条目中。
要怎么做到精确跳转呢?
iOS10以前
通过头部带“prefs”的URL跳转到系统的各种系统设置中:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
}
前提是要在URL Types中添加名为prefs的URL Schemes:
附可以跳转到的各个位置的URL:
prefs:root=General&path=About
prefs:root=General&path=ACCESSIBILITY
prefs:root=AIRPLANE_MODE
prefs:root=General&path=AUTOLOCK
prefs:root=General&path=USAGE/CELLULAR_USAGE
prefs:root=Brightness
prefs:root=General&path=Bluetooth
prefs:root=General&path=DATE_AND_TIME
prefs:root=FACETIME
prefs:root=General