首页 > 代码库 > whose view is not in the window hierarchy
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
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
原文链接:http://www.jianshu.com/p/9e90cb866fdf
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
whose view is not in the window hierarchy
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。