iOS: reload single cell of UICollectionView

后端 未结 5 1505
無奈伤痛
無奈伤痛 2021-01-11 19:21

I am trying to follow the following post on reload a cell in a UICollectionView:

UICollectionView update a single cell

I know that I ultimately want somethin

5条回答
  •  不思量自难忘°
    2021-01-11 20:01

    Toy have to pass an array containing the indexPaths that you want to be reloaded.

    [self.collectionView reloadItemsAtIndexPaths: indexpathArray];
    

    NSIndexPath has some property names section and row, both represents a cell. If your collection view has single section, you can create a NSIndexPath by setting its section = 0;

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:0];
    

    Here rowIndex is your array index. Btw you have to make an array with you newly created indexpaths, then pass it to reloadItemsAtIndexPaths.

    Hope this helps.. :)

提交回复
热议问题