前言
在開發(fā)中, 我們有很多各式各樣的需求需要用戶跳轉(zhuǎn)到系統(tǒng)的設(shè)置頁進(jìn)行設(shè)置. 比如IM關(guān)閉通知的聲音,震動; VPN設(shè)置, 時間設(shè)置等等...
jump
跳轉(zhuǎn)到系統(tǒng)的設(shè)置頁主頁, 在iOS8.0的時候, Apple出了這么個玩意UIApplicationOpenSettingsURLString, 可以跳轉(zhuǎn)到系統(tǒng)設(shè)置主頁
let settingUrl =NSURL(string:UIApplicationOpenSettingsURLString)!ifUIApplication.sharedApplication().canOpenURL(settingUrl)? {UIApplication.sharedApplication().openURL(settingUrl) }
跳轉(zhuǎn)到其他設(shè)置頁(以下皆copy自Stack OverFlow), 只需要修改上面代碼的目標(biāo)URL即可
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=BluetoothDate&Time— prefs:root=General&path=DATE_AND_TIME? FaceTime — prefs:root=FACETIMEGeneral— prefs:root=GeneralKeyboard — prefs:root=General&path=Keyboard? iCloud — prefs:root=CASTLE? iCloudStorage&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 VolumeLimit— 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=ManagedConfigurationListReset— prefs:root=General&path=ResetSafari — prefs:root=Safari? Siri — prefs:root=General&path=Assistant? Sounds — prefs:root=Sounds? SoftwareUpdate— prefs:root=General&path=SOFTWARE_UPDATE_LINKStore— prefs:root=STORETwitter — prefs:root=TWITTERUsage— prefs:root=General&path=USAGEVPN — prefs:root=General&path=Network/VPN? Wallpaper — prefs:root=Wallpaper? Wi-Fi — prefs:root=WIFI? Setting —prefs:root=INTERNET_TETHERING
一個小tip: 盡量用真機進(jìn)行測試,? 模擬器很多地方你是跳不過去的...我測試了, iOS8.4(iphone5), iOS9.0(iphone6), iOS9.1(iphone5s), iOS9.2(iphone5s), 跳轉(zhuǎn)都是正常的. iOS5.1到iOS7貌似是不行的, 這個我沒測試, 有興趣的同學(xué)可以試一試, 告訴我結(jié)果. 謝謝...
補充: 06-09:
跳轉(zhuǎn)到應(yīng)用對應(yīng)的設(shè)置頁:
[[UIApplication sharedApplication]openURL:[NSURL URLWithString: UIApplicationOpenSettingsURLString]];