UICollectionView与UITableView类似,都可以使用reloadData来进行cell内容的更新。然而如果想要进行局部cell更新呢?
[self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
传入参数就是要刷新的cell所在的indexPath组成的数组。
但,reloadItemsAtIndexPath默认会有一个动画的过程,cell内容更新的瞬间会出现原内容与新内容重叠的情况。那么使用如下方式取消该动画即可:
[UIView performWithoutAnimation:^{ [self.collectionView reloadItemsAtIndexPaths:@[indexPath]]; }];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];而使用reloadData进行全部cell的更新,则没有这个默认的动画过程。