在OSX Cocoa应用程序中,我想要一个可以打开"语音"首选项窗格的按钮.那可能吗?我只是想节省他们去系统首选项>语音>文本到语音的时间
我想创建一个警报,在用户第一次拒绝使用相机后将用户重定向到设置应用程序,但到目前为止我看到的唯一方法是使用 UIKit 和
let settingsAction = UIAlertAction(title: "Settings", style: .default, handler: {action in
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
})
Run Code Online (Sandbox Code Playgroud)
在 SwiftUI 中,警报中有一个操作选项,我如何才能通过 SwiftUI 的警报版本正确打开设置?
.alert(isPresented: $alertVisible) { () -> Alert in Alert (title: Text("Camera access required to take photos"), message: Text("Go to Settings?"),
primaryButton: .default(Text("Settings"), action: UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)),
secondaryButton: .default(Text("Cancel"))
Run Code Online (Sandbox Code Playgroud)