最近在项目中实现一个表情切换的控件,刚写时,时间比较紧张,在实现的过程中,系统打印了一个警告,警告内容如下:
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的设置.