?
當 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
數據來源cocoaChina
?