码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2015-04-14 18:10:48      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:ios   hierarchy   uiviewcontroller   界面   

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

问题,从UICollectionViewController 的cell选中present(模态)到UITableViewController 时,出现错误,显示如下:
Warning: Attempt to present A on B whose view is not in the window hierarchy!


查资料后说是视图混乱
需改如下 
在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];

技术分享




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

标签:ios   hierarchy   uiviewcontroller   界面   

原文地址:http://blog.csdn.net/u010070526/article/details/45043639

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!