首页 > 其他 > 详细

自定义layout中需要重写的方法

时间:2016-02-21 19:58:11      阅读:373      评论:0      收藏:0      [点我收藏+]

Layout类中,有3个方法是必定会被依次调用:

  1. prepareLayout: 准备所有view的layoutAttribute信息

  2. collectionViewContentSize: 计算contentsize,显然这一步得在prepareLayout之后进行

  3. layoutAttributesForElementsInRect: 返回在可见区域的view的layoutAttribute信息,

    这个方法不写 集合视图显示不出来,这个方法是将保存的每个item的信息告诉集合视图,进行显示。

 

此外,还有其他方法可能会被调用:

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath { } 
- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { } 
- (UICollectionViewLayoutAttributes *)layoutAttributesForDecorationViewOfKind:(NSString *)decorationViewKind atIndexPath:(NSIndexPath *)indexPath { } 
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { }

自定义layout中需要重写的方法

原文:http://www.cnblogs.com/dabaomo/p/5205417.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!