前言
在开发中, 我们有很多各式各样的需求需要用户跳转到系统的设置页进行设置. 比如IM关闭通知的声音,震动; VPN设置, 时间设置等等...
jump
跳转到系统的设置页主页, 在iOS8.0的时候, Apple出了这么个玩意UIApplicationOpenSettingsURLString, 可以跳转到系统设置主页
let settingUrl =NSURL(string:UIApplicationOpenSettingsURLString)!ifUIApplication.sharedApplication().canOpenURL(settingUrl) {UIApplication.sharedApplication().openURL(settingUrl) }
跳转到其他设置页(以下皆copy自Stack OverFlow), 只需要修改上面代码的目标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: 尽量用真机进行测试, 模拟器很多地方你是跳不过去的...我测试了, iOS8.4(iphone5), iOS9.0(iphone6), iOS9.1(iphone5s), iOS9.2(iphone5s), 跳转都是正常的. iOS5.1到iOS7貌似是不行的, 这个我没测试, 有兴趣的同学可以试一试, 告诉我结果. 谢谢...
补充: 06-09:
跳转到应用对应的设置页:
[[UIApplication sharedApplication]openURL:[NSURL URLWithString: UIApplicationOpenSettingsURLString]];