简体   繁体   English

Swift 3中的“设置”按钮,Xcode

[英]Settings button in swift 3, Xcode

The problem I have is that I want to have a settings button which when the user clicks it, takes them to a specified path in the settings such as sound settings. 我的问题是我想要一个设置按钮,当用户单击该按钮时,会将它们带到设置中的指定路径,例如声音设置。 The only issue is that every method I've tried has been outdated for more recent versions of iOS 10. Does anyone have any suggestions for a method which I can use? 唯一的问题是,我尝试过的每种方法在iOS 10的较新版本中都已过时。有人对我可以使用的方法有任何建议吗? Any help will be greatly appreciated. 任何帮助将不胜感激。

You can open your app Settings page by... 您可以通过以下方式打开应用的Settings页面:

let settings_app: URL = URL(string: UIApplicationOpenSettingsURLString)!
UIApplication.shared.open(settings_app)

But you can't open other Settings app section from any app. 但是您无法从任何应用程序打开其他“设置”应用程序部分。

Try the following code, I hope to help you 试试下面的代码,希望对您有所帮助

let settingsUrl = NSURL(string:UIApplicationOpenSettingsURLString) as! URL
if #available(iOS 10.0, *) {
    UIApplication.shared.open(settingsUrl, options: [:], completionHandler: nil)
} else {
    // Fallback on earlier versions
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM