创建自定义window窗口时:
let _window : UIWindow = UIWindow()
_window.frame = UIScreen.main.bounds
_window.windowLevel = UIWindow.Level.normal
_window.rootViewController = UIViewController()
_window.backgroundColor = UIColor.clear
_window.makeKeyAndVisible()
创建后直接present一个viewcontroller:
_window.rootViewController?.present(vc, animated: false, completion: {
})
会无法弹出这个窗口,控制台报错为:
Unbalanced calls to begin/end appearance transitions for <XXXViewController: 0x7fcea3730650>.
是因为创建windown时 makeKeyAndVisible() 动画还没完成就present领一个动画造成的,就算把present animated设为false,也还是报错。
解决办法就是把这两个方法拆开,不要放到一起。。。
网友评论