关闭

IOS indexPathsForVisibleItems原理

24人阅读 评论(0) 收藏 举报
通过对UICollectionView的滑动 打印

NSArray *cellIndices = [self.collectionViewindexPathsForVisibleItems];

NSLog(@"%@",cellIndices);

结果:1.

(

    "<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}"

)

2.

(

    "<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}",

    "<NSIndexPath: 0xc000000000000056> {length = 2, path = 1 - 0}"

)

3.

(

    "<NSIndexPath: 0xc000000000000096> {length = 2, path = 2 - 0}",

    "<NSIndexPath: 0xc000000000000056> {length = 2, path = 1 - 0}"

)

4.

(

    "<NSIndexPath: 0xc000000000000096> {length = 2, path = 2 - 0}",

    "<NSIndexPath: 0xc0000000000000d6> {length = 2, path = 3 - 0}"

)

5.

(

    "<NSIndexPath: 0xc0000000000000d6> {length = 2, path = 4 - 0}"

    "<NSIndexPath: 0xc0000000000000d6> {length = 2, path = 3 - 0}"

)

6.

(

    "<NSIndexPath: 0xc0000000000000d6> {length = 2, path = 4 - 0}"

    "<NSIndexPath: 0xc0000000000000d6> {length = 2, path = 5 - 0}"

)

......


结论:系统对可见cell的复用原理是替换原先的旧值,这里我们就必须特殊的使用这个复用数组。


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:37次
    • 积分:20
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:0篇
    • 译文:1篇
    • 评论:0条
    文章存档