下面是一些報錯
1,描述
2016-11-09 14:36:02.158 BigSport[11199:168096] The behavior of the UICollectionViewFlowLayout is not defined because:
2016-11-09 14:36:02.158 BigSport[11199:168096] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values.
2016-11-09 14:36:02.159 BigSport[11199:168096] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7fb746628ab0>, and it is attached to <UICollectionView: 0x7fb748082000; frame = (0 64; 375 554); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x60800024cf00>; layer = <CALayer: 0x608000039b60>; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <UICollectionViewFlowLayout: 0x7fb746628ab0>.
2016-11-09 14:36:02.159 BigSport[11199:168096] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2016-11-09 14:36:03.263 BigSport[11199:168096] The behavior of the UICollectionViewFlowLayout is not defined because:
2016-11-09 14:36:03.263 BigSport[11199:168096] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values.
2016-11-09 14:36:03.264 BigSport[11199:168096] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7fb746628ab0>, and it is attached to <UICollectionView: 0x7fb748082000; frame = (0 64; 375 554); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x60800024cf00>; layer = <CALayer: 0x608000039b60>; contentOffset: {0, -54}; contentSize: {375, 2234.5903333333331}> collection view layout: <UICollectionViewFlowLayout: 0x7fb746628ab0>.
2016-11-09 14:36:03.264 BigSport[11199:168096] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2,錯誤原因:
UICollectionViewFlowLayout的itemSize的寬或者高設(shè)置的有問題!它的size必須在父容器的范圍之內(nèi)阶界!
3,解決方案
只要在- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath的方法中修改返回的size就可以了
當然如果你要是謝了這個方法
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section對應哈