前言
在开发中, 我们有很多各式各样的需求需要用户跳转到系统的设置页进行设置. 比如IM关闭通知的声音,震动; VPN设置, 时间设置等等...
jump
- 跳转到系统的设置页主页, 在iOS8.0的时候, Apple出了这么个玩意
UIApplicationOpenSettingsURLString
, 可以跳转到系统设置主页
let settingUrl = NSURL(string: UIApplicationOpenSettingsURLString)!
if UIApplication.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=Bluetooth
Date & Time — prefs:root=General&path=DATE_AND_TIME
FaceTime — prefs:root=FACETIME
General — prefs:root=General
Keyboard — prefs:root=General&path=Keyboard
iCloud — prefs:root=CASTLE
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=Assistant
Sounds — prefs:root=Sounds
Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINK
Store — prefs:root=STORE
Twitter — prefs:root=TWITTER
Usage — prefs:root=General&path=USAGE
VPN — 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]];
联系我
<a href="https://github.com/SunLiner">github</a>
<a href="http://www.weibo.com/5589163526/profile?rightmod=1&wvr=6&mod=personinfo&is_all=1">微博</a>
<a href="//www.greatytc.com/users/9723687edfb5/latest_articles">简书</a>