关闭

UIFlowLayout:the behavior of the UICollectionViewFlowLayout is not defined

标签: flowLayout
156人阅读 评论(0) 收藏 举报
分类:

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

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);
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:11890次
    • 积分:395
    • 等级:
    • 排名:千里之外
    • 原创:27篇
    • 转载:3篇
    • 译文:0篇
    • 评论:3条
    最新评论