我需要打开我的应用程序设置,但是有时如果我们已经打开了其他屏幕设置,例如wifi或代理屏幕,那么它就不会重定向到iOS 13中的App设置。

@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")
   }
}

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

10-06 13:26