UIWindow not showing over content in iOS 13

后端 未结 12 1677
野的像风
野的像风 2020-12-07 17:41

I am upgrading my app to use the new UIScene patterns as defined in iOS 13, however a critical part of the app has stopped working. I have been using a UI

12条回答
  •  佛祖请我去吃肉
    2020-12-07 18:32

    I was experiencing the same problems while upgrading my code for iOS 13 scenes pattern. With parts of your second code snippet I managed to fix everything so my windows are appearing again. I was doing the same as you except for the last line. Try removing viewController.present(...). Here's my code:

    let windowScene = UIApplication.shared
                    .connectedScenes
                    .filter { $0.activationState == .foregroundActive }
                    .first
    if let windowScene = windowScene as? UIWindowScene {
        popupWindow = UIWindow(windowScene: windowScene)
    }
    

    Then I present it like you do:

    popupWindow?.frame = UIScreen.main.bounds
    popupWindow?.backgroundColor = .clear
    popupWindow?.windowLevel = UIWindow.Level.statusBar + 1
    popupWindow?.rootViewController = self as? UIViewController
    popupWindow?.makeKeyAndVisible()
    

    Anyway, I personally think that the problem is in viewController.present(...), because you show a window with that controller and immediately present some 'self', so it depends on what 'self' really is.

    Also worth mentioning that I store a reference to the window you're moving from inside my controller. If this is still useless for you I can only show my small repo that uses this code. Have a look inside AnyPopupController.swift and Popup.swift files.

    Hope that helps, @SirOz

提交回复
热议问题