美文网首页
报错:Unbalanced calls to begin/end

报错:Unbalanced calls to begin/end

作者: 咚咚嗒大人 | 来源:发表于2019-11-23 16:06 被阅读0次
        创建自定义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,也还是报错。
解决办法就是把这两个方法拆开,不要放到一起。。。

相关文章

网友评论

      本文标题:报错:Unbalanced calls to begin/end

      本文链接:https://www.haomeiwen.com/subject/ghphwctx.html