您的位置:首页 > 产品设计 > UI/UE

UIFlowLayout:the behavior of the UICollectionViewFlowLayout is not defined

2016-08-28 19:57 459 查看

一.具体报错的内容如下:

the behavior of the UICollectionViewFlowLayout is not defined because:


the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.


The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7fce90e3d6c0>, and it is attached to <UICollectionView: 0x7fce918f2600; frame = (0 0; 375 200); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x7fce90e3ceb0>; layer = <CALayer: 0x7fce90e3bb70>; contentOffset: {0, 0}; contentSize: {0, 200}> collection view layout: <UICollectionViewFlowLayout: 0x7fce90e3d6c0>.


二. 原因分析

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

父容器UICollectionView的高度为200,但是在设置itemSize高度的时候设置成250了。

self.flowLayout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 250);


三.解决方法

将itemSize的高度也改的和父容器UICollectionView一致,即200.

self.flowLayout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 200);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐