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的层次结构不乱。

时间: 2024-11-07 18:01:49

Attempt to present on whose view is not in the window hierarchy!的相关文章

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

当我想从一个VC跳转到另一个VC的时候,一般会用 - (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion;当然也可以用导航push. 有时会遇到了此类警告:Warning: Attempt to present on whose view is not in the window hier

Swift - whose view is not in the window hierarchy 问题解决方法

问题现象:想在页面初始化的时候,使用self.presentViewController方法弹出个告警提示框UIAlertController.但行后报了个如下告警,同时告警框也出不来. 1 2015-03-10 09:55:34.197 Test[1140:29622] Warning: Attempt to present <UIAlertController: 0x7c95ca20> on <Test.ViewController: 0x7a6afc60> whose vie

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)?

IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法

在 IOS 开发当中经常碰到 whose view is not in the window hierarchy 的错误,该错误简单的说,是由于 "ViewController" 还没有被夹在,就调用该 ViewController 或者 ViewController 内的方法时,就会报这个错误. 在不同地方调用 ViewController,解决的方法也不太一样. 1. 在 一个 ViewController 里面调用另外一个 ViewController 是出现这个错误: 该错误一

Warning: Attempt to present A on B whose view is not in the window hierarchy!

UIViewController 显示的主页面 添加了一个scrollView UICollectionViewController 自带collectionView UITableViewController A自带 tableView UITableViewController  B 被present的界面 把collectionView,tableView 添加到scrollView上以显示滑动效果 问题,从UICollectionViewController 的cell选中present

Warning: Attempt to present &lt;UIAlertController: 0x7fb6ab704950&gt; on &lt;UIViewController: 0x7fb6ab51c810&gt; whose view is not in the window hierarchy!

对于在UIView上,是不能跳转的,所以我们通常要借助UIViewController,但经常会出现UIViewController没被加载的情况.这时就会报这个错. 解决方法: viewCon = (UIApplication.shared.keyWindow?.rootViewController)!  self.viewCon.present(alertView, animated: true, completion: nil); 希望后面的童鞋不要掉坑里了哦!!!!

对Warning: Attempt to present XXX on XXX whose view is not in the window hierarchy!的解决方案

下面是我找到的最靠谱的答案了.尝试后问题果然解决了.分享给大家.http://blog.csdn.net/sbvfhp/article/details/19826221 当我想从一个VC跳转到另一个VC的时候, 一般会用- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion;当然也可以用导

whose view is not in the window hierarchy! 解决办法

self.view.addSubview(alert.view) self.addChildViewController(alert)

Attempt to present &lt;vc&gt; on &lt;vc&gt; which is already presenting &lt;vc&gt;/(null)

在给 tableViewCell 添加长按手势弹出一个 popViewController 的时候,遇到的这个变态问题: Warning: Attempt to present <UINavigationController: 0x15f259c00>  on <RepoDetailViewController: 0x160271400> which is already presenting (null) 我的solution : 不使用手势去运行此方法.换用了button的ad