UICollectionViewController使用问题之UICollectionViewFlowLayout

时间:2015-01-30 09:08:30   收藏:0   阅读:132

1.  问题描述:

最近在做项目的时候,用到了UICollectionViewController控制器,但是在显示数据的时候,出现了如下的警告信息:

2015-01-28 21:55:17.790 Demo[636:9351] the behavior of the UICollectionViewFlowLayout is notdefined because:

2015-01-28 21:55:17.791 Demo[636:9351]the item height must be less than the height of the UICollectionView minus thesection insets top and bottom values.

” 很纠结,检查了很久才发现了问题的原因之所在。

2. 错误原因:

UICollectionViewFlowLayout的itemSize的宽或者高设置的有问题!它的size必须在父容器的范围之内!

3. 解决方案:

CGSize screenSize = [UIScreen mainScreen].bounds.size;
// 这里的高度应该减去导航条的高度和状态栏的高度,而不是屏幕的高度!
self.layout.itemSize = CGSizeMake(screenSize.width, screenSize.height - CYNavigationBarHeight - CYStatusBarHeight);


评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!