iOS: reload single cell of UICollectionView

后端 未结 5 1527
無奈伤痛
無奈伤痛 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:04

    Obj-C

    NSMutableArray *indexPaths = [[NSMutableArray alloc] init]    
    [indexPaths addObject:indexPath];
    [self.collectionView reloadItemsAtIndexPaths: indexPaths];
    

    Swift 4.0

    var indexPaths = [IndexPath]()
    indexPaths.append(indexPath) 
    
    if let collectionView = collectionView {
        collectionView.reloadItemsAtIndexPaths(indexPaths)
    }
    

提交回复
热议问题