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(模态)到UITableViewController 时,出现错误,显示如下:

查资料后说是视图混乱

需改如下

在UIViewController的scrollView添加view时,给controller加上两个子类controller 分别为这两个view

// 给view加上子类的controller

 [self addChildViewController:_attention];
 [self addChildViewController:_allControll];
<img src="http://img.blog.csdn.net/20150414164759227?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMDA3MDUyNg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />

改后运行,有效果,但输出台显示如下,

Presenting view controllers on detached view controllers is discouraged <AttentionController: 0x7ff9d40376c0>.

此时应该回到被选中的cell时,添加父controll

[self.parentViewController presentViewController:listVC animated:YES completion:nil];

时间: 2024-11-15 22:53:29

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

对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;当然也可以用导

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

Warning: Attempt to present * on * which is already presenting *

Warning: Attempt to present (要被presented的控制器)  on (哪个控制器来presenting) which is already presenting (已经被presenting的控制器) self: 是被presented出来的控制器, self.presentingViewController: 看看是谁把self给presenting出来 RPLog(@"%@ - %@", self.presentingViewController,

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还没加到wi

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); 希望后面的童鞋不要掉坑里了哦!!!!

iOS8 iPad Warning: Attempt to present &lt;UIImagePickerController:xxxx &gt; on xxxx which is already presenting (null)

解决方法: /* I think this is because in iOS 8, alert views and action sheets are actually presented view controllers (UIAlertController). So, if you're presenting a new view controller in response to an action from the UIAlertView, it's being presented w

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

Attempt to invoke virtual method &#39;int android.view.View.getImportantForAccessibility()&#39;

最近在做和列表或者是Gridview相关显示的出现了一个问题,整理一下思路,分享出来给大家参考一下: 其实不管是LIstView还是GridView都会可能出现,而且原因基本是一样的; // Short Msg: java.lang.NullPointerException // Long Msg: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportan

Warning: Attempt to dismiss from view controller &lt;UIViewController: 0x17d71c10&gt; while a presentation or dismiss is in progress!

昨天 调试程序 已经快要上线了 突然有个BUG 找了半天 才找到是因为这个警告 但是 解决这个警告又花了一天的时间 试了各种消除控制器的方法 都不可用 其中 并且 有这个bug  手机真机测试完全没问题  只有在iPad上 有这个警告 就会出问题 第一个解决办法  试了下 半成品  上下代码 dispatch_after(dispatch_time(DISPATCH_TIME_NOW,(int64_t)(0.51 * NSEC_PER_SEC)),dispatch_get_main_queue(