weiminghuaa
weiminghuaa

Reputation: 147

UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath: wrong indexPath reuse cell

Log in method:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

1st loadData

2016-09-30 15:55:28.764 MYAPP[12950:384498] PosterCell-0: <PosterCell: 0x7fdd3c57cf90>

2016-09-30 15:55:28.782 MYAPP[12950:384498] PosterCell-1: <PosterCell: 0x7fdd3c4cc0c0>

2016-09-30 15:55:28.807 MYAPP[12950:384498] PosterCell-2: <PosterCell: 0x7fdd3c5815e0>

2nd reloadData

2016-09-30 15:55:28.959 MYAPP[12950:384498] PosterCell-0: <PosterCell: 0x7fdd3c5815e0>

2016-09-30 15:55:28.961 MYAPP[12950:384498] PosterCell-1: <PosterCell: 0x7fdd3c57cf90>

2016-09-30 15:55:28.962 MYAPP[12950:384498] PosterCell-2: <PosterCell: 0x7fdd3c4cc0c0>

You see,different XRKPosterCell-0 in two load. Why?

Upvotes: 0

Views: 139

Answers (1)

sushma
sushma

Reputation: 9

Thats because you are reusing the cell that is created using dequeueResuableCell.

Compare reload 1 with reload 2 for other cells too ...You can observe that

postercell-0 in reload1  = postercell1 in reload2
PosterCell-1 in reload1 = PosterCell-2 in reload2
PosterCell-2 in reload1 = PosterCell-0 in reload2.

The cells are just being reused!

Upvotes: 1

Related Questions