当 iOS系统版本 <= iOS7时 , 只能跳转到 系统设置页面 ,楼主试了下,非真机是没有任何效果的
当iOS系统版本 < iOS 10.0 时
NSURL *url= [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];
if( [[UIApplication sharedApplication]canOpenURL:url] ) {
[[UIApplication sharedApplication]openURL:url];
}
当iOS系统版本 >=iOS 10.0 时
if( [[UIApplication sharedApplication]canOpenURL:url] ) {
[[UIApplication sharedApplication]openURL:url options:@{}completionHandler:^(BOOL success) {
}];
}
跳到更多设置界面
除了跳到WiFi设置界面,能不能跳到其他的设置界面呢?比如:定位服务、FaceTime、音乐等等。都是可以的,一起来看看如何实现的!
定位服务
定位服务有很多APP都有,如果用户关闭了定位,那么,我们在APP里面可以提示用户打开定位服务。点击到设置界面设置,直接跳到定位服务设置界面。代码如下:
//定位服务设置界面NSURL *url = [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];if ([[UIApplication sharedApplication] canOpenURL:url]){ [[UIApplication sharedApplication] openURL:url];}
这样就可以跳到系统设置的定位服务界面啦!我们继续看几个列子。
FaceTim
//FaceTime设置界面NSURL *url = [NSURL URLWithString:@"prefs:root=FACETIME"];if ([[UIApplication sharedApplication] canOpenURL:url]){ [[UIApplication sharedApplication] openURL:url];}
音乐
//音乐设置界面NSURL *url = [NSURL URLWithString:@"prefs:root=MUSIC"];if ([[UIApplication sharedApplication] canOpenURL:url]){ [[UIApplication sharedApplication] openURL:url];}
墙纸设置界面
//墙纸设置界面NSURL *url = [NSURL URLWithString:@"prefs:root=Wallpaper"];if ([[UIApplication sharedApplication] canOpenURL:url]){ [[UIApplication sharedApplication] openURL:url];}
蓝牙设置界面
//蓝牙设置界面NSURL *url = [NSURL URLWithString:@"prefs:root=Bluetooth"];if ([[UIApplication sharedApplication] canOpenURL:url]){ [[UIApplication sharedApplication] openURL:url];}
iCloud设置界面
//iCloud设置界面NSURL *url = [NSURL URLWithString:@"prefs:root=CASTLE"];if ([[UIApplication sharedApplication] canOpenURL:url]{ [[UIApplication sharedApplication] openURL:url];}
参数配置
看到这几个例子,大家有没有发现,想跳到哪个设置界面只需要prefs:root=后面的值即可!是的,就是这样的。
我在网上找到一个列表,可以跳到这些界面的参数配置:
About — prefs:root=General&path=AboutAccessibility — prefs:root=General&path=ACCESSIBILITYAirplane Mode On — prefs:root=AIRPLANE_MODEAuto-Lock — prefs:root=General&path=AUTOLOCKBrightness — prefs:root=BrightnessBluetooth — prefs:root=General&path=BluetoothDate & Time — prefs:root=General&path=DATE_AND_TIMEFaceTime — prefs:root=FACETIMEGeneral — prefs:root=GeneralKeyboard — prefs:root=General&path=KeyboardiCloud — prefs:root=CASTLEiCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUPInternational — prefs:root=General&path=INTERNATIONALLocation Services — prefs:root=LOCATION_SERVICESMusic — prefs:root=MUSICMusic Equalizer — prefs:root=MUSIC&path=EQMusic Volume Limit — prefs:root=MUSIC&path=VolumeLimitNetwork — prefs:root=General&path=NetworkNike + iPod — prefs:root=NIKE_PLUS_IPODNotes — prefs:root=NOTESNotification — prefs:root=NOTIFICATIONS_IDPhone — prefs:root=PhonePhotos — prefs:root=PhotosProfile — prefs:root=General&path=ManagedConfigurationListReset — prefs:root=General&path=ResetSafari — prefs:root=SafariSiri — prefs:root=General&path=AssistantSounds — prefs:root=SoundsSoftware Update — prefs:root=General&path=SOFTWARE_UPDATE_LINKStore — prefs:root=STORETwitter — prefs:root=TWITTERUsage — prefs:root=General&path=USAGEVPN — prefs:root=General&path=Network/VPNWallpaper — prefs:root=WallpaperWi-Fi — prefs:root=WIFI