I'm adding new UIWindow to show passcode view controller when the app is entering foreground.
Before iOS 13 in AppDelegate I had property var passcodeWindow = UIWindow(frame: UIScreen.main.bounds) where my rootViewController was the passcode view controller and in applicationWillEnterForeground method I was doing passcodeWindow.makeKeyAndVisible() to place it on the top.
Now when I want to implement the passcode functionality in iOS 13 there is a problem with this approach. I moved it to the sceneWillEnterForeground method in SceneDelegate, but it seems like I can't show passcodeWindow on top of the actual window in this scene.
I do it exactly the same as in AppDelegate and the passcodeWindow is not shown.
The way I do it in sceneWillEnterForeground in AppDelegate and in SceneDelegate:
passcodeWindow.rootViewController = passcodeViewController(type: .unlock)
passcodeWindow.makeKeyAndVisible()
I expect passcodeWindow to show on the top of current window in the scene.
You can try this:
if #available(iOS 13.0, *) {
if let currentWindowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
passcodeWindow.windowScene = currentWindowScene
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With