UIWindow not showing over content in iOS 13

后端 未结 12 1681
野的像风
野的像风 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:23

    Need have pointer a created window for ios13.

    example my code:

     extension UIAlertController {
    
        private static var _aletrWindow: UIWindow?
        private static var aletrWindow: UIWindow {
            if let window = _aletrWindow {
                return window
            } else {
                let window = UIWindow(frame: UIScreen.main.bounds)
                window.rootViewController = UIViewController()
                window.windowLevel = UIWindowLevelAlert + 1
                window.backgroundColor = .clear
                _aletrWindow = window
                return window
            }
        }
    
        func presentGlobally(animated: Bool, completion: (() -> Void)? = nil) {
            UIAlertController.aletrWindow.makeKeyAndVisible()
            UIAlertController.aletrWindow.rootViewController?.present(self, animated: animated, completion: completion)
        }
    
        open override func viewDidDisappear(_ animated: Bool) {
            super.viewDidDisappear(animated)
            UIAlertController.aletrWindow.isHidden = true
        }
    
    }
    

    use:

    let alert = UIAlertController(...
    ...
    
    alert.presentGlobally(animated: true)
    

提交回复
热议问题