有时候,我们为了让用户方便地设置一些内容,希望可以让用户点击一个按钮,就可以跳转到 设置->通用,或 设置->�Safari,等『设置App』中的详细条目,这样,下面这条常见的语句就不足以满足需求了:
UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
(这条语句可以跳转到 设置App)
但是如果我们需要跳转到 设置->Safari 这个地方,就要写下面这样的语句:
#if arch(i386) || arch(x86_64)
// Simulator
let url = NSURL(string: "prefs:root=Safari")!
#else
// Device
let url = NSURL(string: "prefs:root=SAFARI")!
#endif
if UIApplication.sharedApplication().canOpenURL(url) {
UIApplication.sharedApplication().openURL(url)
}
这种形式直接被写出来的话,在 iOS 5.1 及更高版本中,不会起作用,所以需要做的额外一个步骤是:

在 YourAppTarget->Info->URL Types 这个地方,如上图,写上 prefs 字段;这样在 iOS 8 及 iOS 9 中都亲测有效。
下面给出一个较为完整的列表,可以让你随意跳转到 设置App 里的任意一个地方 :)
【List of currently known URLs in the Settings app】
prefs:root=General&path=About
prefs:root=General&path=ACCESSIBILITY
prefs:root=AIRPLANE_MODE
prefs:root=General&path=AUTOLOCK
prefs:root=General&path=USAGE/CELLULAR_USAGE
prefs:root=Brightness
prefs:root=General&path=Bluetooth
prefs:root=General&path=DATE_AND_TIME
prefs:root=FACETIME
prefs:root=General
prefs:root=General&path=Keyboard
prefs:root=CASTLE
prefs:root=CASTLE&path=STORAGE_AND_BACKUP
prefs:root=General&path=INTERNATIONAL
prefs:root=LOCATION_SERVICES
prefs:root=ACCOUNT_SETTINGS
prefs:root=MUSIC
prefs:root=MUSIC&path=EQ
prefs:root=MUSIC&path=VolumeLimit
prefs:root=General&path=Network
prefs:root=NIKE_PLUS_IPOD
prefs:root=NOTES
prefs:root=NOTIFICATIONS_ID
prefs:root=Phone
prefs:root=Photos
prefs:root=General&path=ManagedConfigurationList
prefs:root=General&path=Reset
prefs:root=Sounds&path=Ringtone
prefs:root=Safari
prefs:root=General&path=Assistant
prefs:root=Sounds
prefs:root=General&path=SOFTWARE_UPDATE_LINK
prefs:root=STORE
prefs:root=TWITTER
prefs:root=General&path=USAGE
prefs:root=VIDEO
prefs:root=General&path=Network/VPN
prefs:root=Wallpaper
prefs:root=WIFI
prefs:root=INTERNET_TETHERING
引用内容来源:
http://stackoverflow.com/questions/9092142/ios-uialertview-button-to-go-to-setting-app
http://stackoverflow.com/questions/8246070/ios-launching-settings-restrictions-url-scheme/33896318#33896318
提醒:
这是私有 API,在 AppStore 上架 App 中,请小心谨慎使用。
网友评论
第三方App的URL倒是很容易搞到:http://www.jianshu.com/p/28f517775214