The behavior of the UICollectionViewFlowLayout is not defined because:

关于UICollectionView那些年收到的警告

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 , and it is attached to ; layer = ; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: .

Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

分析

当你收到这个警告的时候,你需要从三个方面分析一下你CollectionView

1.collectionViewCell和collectionView的内边距

如果你写了代理方法你就看看你下面这个方法

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(顶, 左, 底, 右);
}

和UICollectionViewFlowLayout的sectionInset方法同作用

2.UICollectionViewFlowLayoutd的itemSize的size

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(宽,高);
}

和UICollectionViewFlowLayout的itemSize方法同作用

3.你的UICollectionView的宽高

假设你的UICollectionView的高度是70,你的UICollectionViewFlowLayout的sectionInset的高度设置的也是是70,理所应当,你的UIEdgeInsetsMake的顶部和底部的距离就是0,如果你还强行设置一个大于o的高度,你就会报如题上面的警告。换成宽度也是一样
所以UICollectionView的宽高要设置合适才不会报警告

你可能感兴趣的:(The behavior of the UICollectionViewFlowLayout is not defined because:)