I\xc2\xb4m 是 SwiftUI 中的新功能。我想知道当用户按下应用程序中的按钮时,如何从 iPhone 打开设置应用程序中的应用程序设置。
\n基于此,您可以使用以下示例代码:
import SwiftUI
struct ContentView: View {
var body: some View {
Button(action: {self.settingsOpener()} ){
Text("Open Settings")
}
}
private func settingsOpener(){
if let url = URL(string: UIApplication.openSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1872 次 |
| 最近记录: |