跳转到设置各个页面,如果想访问子目录,加上大的目录&path=子目录名字(大写)。例如 要访问 设置 -> 隐私 -> 通讯录对应是 prefs:root=Privacy&path=CONTACTS,prefs:root=Privacy就是说第一级目录就是Privacy,其中Privacy就是隐私,CONTACTS就是通讯录,他们之间用&链接起来。
1、跳转到设置页面关于 (iOS10以前)
About — prefs:root=General&path=About (关于)
Accessibility — prefs:root=General&path=ACCESSIBILITY(辅助功能)
Airplane Mode On — prefs:root=AIRPLANE_MODE
Auto-Lock — prefs:root=General&path=AUTOLOCK(通用)
Brightness — prefs:root=Brightness(找不到,跳到设置页面)
Bluetooth — prefs:root=General&path=Bluetooth
Date & Time — prefs:root=General&path=DATE_AND_TIME(时间)
FaceTime — prefs:root=FACETIME(FaceTime)
General — prefs:root=General(通用)
Keyboard — prefs:root=General&path=Keyboard(键盘)
iCloud — prefs:root=CASTLE(iCloud)
iCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP(存储空间)
International — prefs:root=General&path=INTERNATIONAL(语言与地区)
Location Services — prefs:root=LOCATION_SERVICES
Music — prefs:root=MUSIC(音乐)
Music Equalizer — prefs:root=MUSIC&path=EQ
Music Volume Limit — prefs:root=MUSIC&path=VolumeLimit
Network — prefs:root=General&path=Network
Nike + iPod — prefs:root=NIKE_PLUS_IPOD
Notes — prefs:root=NOTES(备忘录)
Notification — prefs:root=NOTIFICATIONS_ID(通知)
Phone — prefs:root=Phone(电话)
Photos — prefs:root=Photos(照片与相机)
Profile — prefs:root=General&path=ManagedConfigurationList(描述文件)
Reset — prefs:root=General&path=Reset(还原)
Safari — prefs:root=Safari(没找到)
Siri — prefs:root=General&path=Assistan
Sounds — prefs:root=Sounds(声音)
Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINK(软件更新)
Store — prefs:root=STORE(iTunes Store与App Store)
Twitter — prefs:root=TWITTER(Twitter)
Usage — prefs:root=General&path=USAGE
VPN — prefs:root=General&path=Network/VPN
Wallpaper — prefs:root=Wallpaper(墙纸)
Wi-Fi — prefs:root=WIFI(无线局域网)
Contacts-- prefs:root=Privacy&path=CONTACTS(通讯录)
代码:
NSURL *url = [NSURL URLWithString:@"prefs:root=General&path=About"];
BOOL isOpen = [[UIApplication sharedApplication] canOpenURL:url];
if (isOpen)
{
[[UIApplication sharedApplication] openURL:url];
}
2、iOS10以后,
(1)、调用canOpenURL:打开系统设置界面时控制台会报如下错误,并且无法跳转:
-canOpenURL: failedforURL:"Prefs:root=Privacy&path=LOCATION"- error:"The operation couldn’t be completed. (OSStatus error -10814.)"
(2)、得到验证打开设置的路径:
Prefs:root=General&path=About (关于)
Prefs:root=General&path=ACCESSIBILITY(辅助功能)
Prefs:root=General&path=AUTOLOCK(通用)
Prefs:root=Brightness(找不到,跳到设置页面)
Prefs:root=General&path=DATE_AND_TIME(时间)
Prefs:root=FACETIME(FaceTime)
Prefs:root=General(通用)
Prefs:root=General&path=Keyboard(键盘)
Prefs:root=CASTLE(iCloud)
Prefs:root=CASTLE&path=STORAGE_AND_BACKUP(存储空间)
Prefs:root=General&path=INTERNATIONAL(语言与地区)
Prefs:root=LOCATION_SERVICES(找不到,跳到设置页面)
Prefs:root=MUSIC(音乐)
Prefs:root=MUSIC&path=EQ(音乐均衡器)
Prefs:root=MUSIC&path=VolumeLimit(音乐的音量限制)
Prefs:root=NOTES(备忘录)
Prefs:root=NOTIFICATIONS_ID(通知)
Prefs:root=Phone(电话)
Prefs:root=Photos(照片与相机)
Prefs:root=General&path=ManagedConfigurationList(描述文件)
Prefs:root=General&path=Reset(还原)
Prefs:root=Sounds(声音)
Prefs:root=General&path=SOFTWARE_UPDATE_LINK(软件更新)
Prefs:root=STORE(iTunes Store与App Store)
Prefs:root=TWITTER(Twitter)
Prefs:root=Wallpaper(墙纸)
Prefs:root=WIFI(无线局域网)
Prefs:root=Privacy&path=CONTACTS(通讯录)
(3)、跳转到设置页面关于 (iOS10以后)注意首字母改成了大写,prefs->Prefs
可以使用MobileCoreServices.framework里的私有API:
- (BOOL)openSensitiveURL:(id)arg1 withOptions:(id)arg2;
头文件参考:LSApplicationWorkspace.h
代码:
NSString *urlString = @"Prefs:root=General&path=About";
NSURL*url=[NSURL URLWithString:urlString];
Class LSApplicationWorkspace = NSClassFromString(@"LSApplicationWorkspace");
[[LSApplicationWorkspace performSelector:@selector(defaultWorkspace)] performSelector:@selector(openSensitiveURL:withOptions:) withObject:url withObject:nil];
总结:
A、自从iOS10以后好像不太支持打开系统的页面,总来说不稳定,例如使用私有API的app无法通过App Store审核,把私有类名和selector字符串混淆一下做一些处理例如:
- (UIView *)statusBarView
{
UIView *statusBar = nil;
NSData *data = [NSData dataWithBytes:(unsigned char []){0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x61, 0x72} length:9];
NSString *key = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
id object = [UIApplication sharedApplication];
if ([object respondsToSelector:NSSelectorFromString(key)])
{
statusBar = [object valueForKey:key];
}
return statusBar;
}
B、路径要在Xcode的plist的LSApplicationQueriesSchemes添加备案,iOS10的系统URLScheme改成了首字母大写,使用小写的方式会无法打开。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>Prefs:root=General&path=Aboutt</string>
</array>