diff --git a/openHAB/OpenHABRootViewController.swift b/openHAB/OpenHABRootViewController.swift index 9d1f95f0c..097a8e9bf 100644 --- a/openHAB/OpenHABRootViewController.swift +++ b/openHAB/OpenHABRootViewController.swift @@ -179,7 +179,11 @@ class OpenHABRootViewController: UIViewController { if let menu = SideMenuManager.default.rightMenuNavigationController { // don't try and push an already visible menu less you crash the app dismiss(animated: false) { - var topMostViewController = UIApplication.shared.keyWindow?.rootViewController + var topMostViewController: UIViewController? = if #available(iOS 13, *) { + UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.last { $0.isKeyWindow }?.rootViewController + } else { + UIApplication.shared.keyWindow?.rootViewController + } while let presentedViewController = topMostViewController?.presentedViewController { topMostViewController = presentedViewController }