15 application-settings swift ios8.3
我正在使用swift和ios 8.3.我想从我的应用程序中打开设置应用程序.我知道使用代码
UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
Run Code Online (Sandbox Code Playgroud)
将打开我的应用设置.但我不想打开我的应用程序设置.我只想打开设置应用程序并保留在主页面中.如果可能,请导航至"Cellular".有没有办法实现这个?
Der*_*ike 21
试试这个.
if let appSettings = URL(string: UIApplicationOpenSettingsURLString) {
UIApplication.shared.open(appSettings, options: [:], completionHandler: nil)
}
Run Code Online (Sandbox Code Playgroud)
Xcode 8.2.1 - iOS 10
DàC*_*hún 16
2016年10月11日更新:
它不再适用于iOS10.到目前为止,我还没有找到任何解决方法.如果你们有任何解决方案,请告诉我.谢谢.
======================================
你可以这样做:
let url:NSURL! = NSURL(string : "prefs:root=")
UIApplication.sharedApplication().openURL(url)
Run Code Online (Sandbox Code Playgroud)
我在github上有一个演示:http://github.com/zhihuitang/SettingDemo.git
您可以找到所有可用的URL,如下所示:http: //iphonedevwiki.net/index.php/Preferences.app 首选项应用程序注册私有URL方案,首选项:,下面的列表详细说明打开特定的视图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
Run Code Online (Sandbox Code Playgroud)
希望这对你有所帮助.
小智 7
是的,他们在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)")
})
}
Run Code Online (Sandbox Code Playgroud)
不要忘记投票并标记为正确答案