Question: 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.

Answer: 
You can try this:

```
if #available(iOS 13.0, *) {
    if let currentWindowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
        passcodeWindow.windowScene = currentWindowScene
    }
}

```
You need a strong reference for your UIWindow instance, and the most important thing is that you need to set "isHidden" property false.

```
newWindow = UIWindow.init(frame: CGRect.init(x: 0, y: 0, width: 100, height: 100))
newWindow?.backgroundColor = UIColor.systemBlue
newWindow?.windowScene = (scene as? UIWindowScene)
newWindow?.isHidden = false

```