繁体   English   中英

iOS:13 位置始终允许:点击打开设置后,它不会重定向到应用程序设置页面

[英]iOS: 13 Location Always Allow: After tapping on Open Settings, it does not redirect to App Settings page

我需要打开我的应用程序设置,但有时如果我们打开了将其他屏幕设置为 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")
   }
}

我希望这个能帮上忙...!

这在我的应用程序中运行良好,为 iOS 12 及更高版本构建,在模拟器和真实设备上测试

UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)

暂无
暂无

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

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