您的位置:首页 > 其它

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

2015-04-14 16:16 323 查看
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];

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐