Attempt to present on whose view is not in the window hierarchy!

在开发的时候,有时候会遇到

1.ios attempt to present whose view is not in the window hierarchy

2.Warning: Attempt to present on whose view is not in the window hierarchy!

等等这样类似的提示,只要里面提示有 window hierarchy,都是view hierarchy的理解不到位导致的。

上面的问题都是在一个controller的view还没加到window上的时候又取present另外一个controller,这就相当于在盖楼,2楼还没盖完,直接去盖3楼了,这样肯定是不行。

遇到上面的问题 最直接的解决方法就是在controller的viewDidAppear里面去调用present。这样可以确保view hierarchy的层次结构不乱。

Attempt to present on whose view is not in the window hierarchy!

上一篇:Windows8新功能


下一篇:骁龙870和骁龙778Gplus哪个好 骁龙870和骁龙778Gplus性能对比