我正在使用iOS 8.3和Swift。我想从我的应用程序打开设置应用程序。我知道可以使用以下代码:
UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
将打开我的应用程序设置。但我不想打开我的应用程序设置。我只想打开设置应用程序并停留在主页面。如果可能,导航到“移动网络”。是否有方法可以实现这个目标?
我正在使用iOS 8.3和Swift。我想从我的应用程序打开设置应用程序。我知道可以使用以下代码:
UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
将打开我的应用程序设置。但我不想打开我的应用程序设置。我只想打开设置应用程序并停留在主页面。如果可能,导航到“移动网络”。是否有方法可以实现这个目标?
试试这个。
if let appSettings = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(appSettings, options: [:], completionHandler: nil)
}
Xcode 11.5 - iOS > 10
2016年10月11日更新:
iOS10中它将不再有效。到目前为止,我还没有找到任何解决方法。如果你们有任何解决方案,请告诉我。谢谢。
======================================
您可以这样做:
let url:NSURL! = NSURL(string : "prefs:root=")
UIApplication.sharedApplication().openURL(url)
我在github上有一个演示:http://github.com/zhihuitang/SettingDemo.git
你可以在下面找到所有可用的URL: http://iphonedevwiki.net/index.php/Preferences.app Preferences应用程序注册了一个私有的URL方案,prefs:,下面的列表详细说明了如何打开特定视图 1[2]
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=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
希望这对你有所帮助。
是的,在iOS 10中进行了更改,请将“prefs:”更改为“App-Prefs:”。
guard let profileUrl = URL(string:"App-Prefs:root=General&path=ManagedConfigurationList") else {
return
}
if UIApplication.shared.canOpenURL(profileUrl) {
UIApplication.shared.open(profileUrl, completionHandler: { (success) in
print(" Profile Settings opened: \(success)")
})
}
// System settings:
let url = URL(string: UIApplication.openSettingsURLString)!
UIApplication.shared.open(url)
// Notifications settings:
URL(string: UIApplication.openNotificationSettingsURLString)!
UIApplication.shared.open(url)