In iOS 13,there is a new behaviour for modal view controller when being presented. Now it's not fullscreen by default, and when i try to change modalPresentationStyle to .fullScreen my view present and dismiss immediately.
I'm presenting view controller with code :
if #available(iOS 13.0, *) {
var popupWindow: UIWindow?
let windowScene = UIApplication.shared
.connectedScenes
.filter { $0.activationState == .foregroundActive }
.first
if let windowScene = windowScene as? UIWindowScene {
popupWindow = UIWindow(windowScene: windowScene)
}
let vc = UIViewController()
vc.view.frame = UIScreen.main.bounds
popupWindow?.frame = UIScreen.main.bounds
popupWindow?.backgroundColor = .clear
popupWindow?.windowLevel = UIWindow.Level.statusBar + 1
popupWindow?.rootViewController = vc
popupWindow?.makeKeyAndVisible()
popupWindow?.rootViewController?.present(self, animated: true, completion: nil)
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…