ios - iOS:13 位置始终允许:点击打开设置后,它不会重定向到应用设置页面
问题描述
我需要打开我的应用程序设置,但有时如果我们打开了将其他屏幕设置为 wifi 或代理屏幕,那么它不会重定向到 iOS 13 中的应用程序设置。
@IBAction func openPhoneSettings(_ sender: Any) {
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString),
UIApplication.shared.canOpenURL(settingsUrl) else {
return
}
UIApplication.shared.open(settingsUrl, options: [:]) { (canOpen) in
self.dismiss(animated: false, completion: nil)
}
}
解决方案
我为打开应用程序设置创建了功能,这对我来说在所有情况下都可以重定向到应用程序设置
func openAppSetting()
{
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {return}
if UIApplication.shared.canOpenURL(settingsUrl)
{
if #available(iOS 10.0, *)
{
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: \(success)")
})
}
else
{
UIApplication.shared.openURL(settingsUrl as URL)
}
}
else
{
print("Settings not opened")
}
}
我希望这个能帮上忙...!
推荐阅读
- angularjs - AngularJS 自定义事件指令不更新布局
- android - 如何在片段中添加网址图像?
- python - XGBoost R vs python - 不同的性能和功能重要性
- linux - 如何撤消'svn revert'?
- c# - 字符串操作 C# - 文本中的断线
- c# - MahApps Metro 主题 - 始终在 WPF 应用程序中的所有其他窗口前面显示对话框窗口
- java - 在新线程()之外的字段之前同步
- javascript - 如何在 html 对象上附加 React 组件?
- batch-file - 一个方便的 .BAT 文件,用于更新本地 Sybase SQL DB
- android - 在 LG Q6 上以编程方式更改导航栏颜色