The behavior of the UICollectionViewFlowLayout is not defined because 解决办法!


最近在项目中实现一个表情切换的控件,刚写时,时间比较紧张,在实现的过程中,系统打印了一个警告,警告内容如下:


2017-08-07 15:04:13.162405 BeautyMain[10202:2018017] The behavior of the UICollectionViewFlowLayout is not defined because:

2017-08-07 15:04:13.162430 BeautyMain[10202:2018017] 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.

2017-08-07 15:04:13.162568 BeautyMain[10202:2018017] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x10fedcdb0>, and it is attached to <UICollectionView: 0x1040c6c00; frame = (0 41; 414 231); clipsToBounds = YES; tag = 10086999; gestureRecognizers = <NSArray: 0x17085f710>; layer = <CALayer: 0x170a3ea60>; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <UICollectionViewFlowLayout: 0x10fedcdb0>.

2017-08-07 15:04:13.162876 BeautyMain[10202:2018017] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.


通过翻译,我们可以看到:

UICollectionViewFlowLayout的行为没有定义,因为:

该项目的高度必须小于UICollectionView的高度,减去inset的顶部和底部的值,减去内容的顶部和底部的值。


这句话说了那么多,感觉看起来,好复杂样子,其实真实的原因 就是这么一句话,加载的Cell的高度大于,UICollectionView的高度。这样就会回导致上面的警告。


解决办法: 认真,仔细,检查UICollectionView的创建frame 以及 UICollectionViewFlowLayout的 itemSize的设置.




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值