我正在使用此代码从我的应用程序尝试打开常规设置iOS,但这会打开设置应用程序视图,而不是常规。
let alert = UIAlertController(
title: "IMPORTANT",
message: "Camera access required for QR Scanning",
preferredStyle: UIAlertController.Style.alert
)
alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil))
alert.addAction(UIAlertAction(title: "Allow", style: .cancel, handler: { (alert) -> Void in
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:] )
}))
present(alert, animated: true, completion: nil)
是否可以使用正确的代码打开一般视图以避免Apple拒绝使用“App-Prefs:root = General”?
导航用户使用您的应用程序设置是人机界面指南推荐的正确方法:
在适当的时候提供设置的快捷方式。如果您的应用包含将用户定向到“设置”的文本,例如“转到设置> MyApp>隐私>位置服务”,则会提供一个自动打开该位置的按钮。有关开发人员指南,请参阅UIApplication中的openSettingsURLString。 https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/settings/
用户可以使用与您的应用程序相关的所有设置进行操作,包括允许和禁用对相机的访问(您需要的)。