search

Home  >  Q&A  >  body text

ios - UICollectionViewCell 显示问题?

如图,上传一张照片后刚开始显示正常,向上将cell划出屏幕上传好的图片就变到第二个item里了。

上滑屏幕

部分代码:

注册:

[self.pictureCollection registerNib:[UINib nibWithNibName:@"CAPictureCell" bundle:[NSBundle mainBundle]]forCellWithReuseIdentifier:@"capicture"];

代理方法:

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

CAPictureCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"capicture" forIndexPath:indexPath];
cell.upload = self;
cell.indexPath = indexPath;
return cell;

}

求助。

怪我咯怪我咯2822 days ago715

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-17 17:58:34

    This is a problem with your cell reuse. There is no need to use alloc - init after register; there will definitely be objects.
    Then you didn’t understand this sentence:

    cell.upload = self;

    What is the process of passing values?

    reply
    0
  • Cancelreply