whose view is not in the window hierarchy

Posted 勇猛的小黑

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了whose view is not in the window hierarchy相关的知识,希望对你有一定的参考价值。

参考:http://www.jianshu.com/p/9e90cb866fdf

在做界面跳转的时候,我们经常会用到这两个函数

func dismissViewControllerAnimated(flag:Bool, completion: (() ->Void)?)

func presentViewController(viewControllerToPresent:UIViewController, animated flag:Bool, completion: (() ->Void)?)

有时候先把自己所在的这个页面 dismiss 掉,再 present 另外一个页面时,控制台会提示 whose view is not in the window hierarchy 这个错误信息。

解决方法:

 

①如果这两个语句出现按钮点击事件里面

这时只要把 dismiss 这一句注释掉,直接 present 就可以啦。

技术分享
 

②而如果这种语句出现在 ViewDidLoad 方法中

 

 

那么则应该把语句转移到 ViewDidAppear 方法中,毕竟你不能对一个只 Load 完毕,却还没有 Appear 出来的 ViewController 要求太多 :)



文/KyXu大魔王(简书作者)
原文链接:http://www.jianshu.com/p/9e90cb866fdf
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。





以上是关于whose view is not in the window hierarchy的主要内容,如果未能解决你的问题,请参考以下文章

Lettuce: Connection to xxx not allowed. This partition is not known in the cluster view.

Lettuce: Connection to xxx not allowed. This partition is not known in the cluster view.

Lettuce: Connection to xxx not allowed. This partition is not known in the cluster view.

BottomSheetBehavior 之 java.lang.IllegalArgumentException: The view is not associated with BottomShe

#### is not in the sudoers file. This incident

UISearchController Attempting to load the view of a view controller while it is deallocating is not