collection view 开发笔记

@interface UICollectionViewLayout (UISubclassingHooks) 各个协议方法的执行顺序

- (void)prepareLayout

- (CGSize)collectionViewContentSize

- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect //会随着滚动不停的调用 前提是shouldInvalidateLayoutForBoundsChange显示的返回YES

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath //为每个cell 确定layoutAttributes

- (CGSize)collectionViewContentSize


以上方法是collectionView在第一次绘制cell时的调用顺序

开始滚动后将以下代理方法显示的返回YES 则方法layoutAttributesForElementsInRect才会在滚动过程中不断调用。
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds

原文地址:https://www.cnblogs.com/ceasar/p/5264892.html