本文共 602 字,大约阅读时间需要 2 分钟。
UICollectionView 与 UITableView类似,都可以使用 reloadData 方法来进行所有 cell内容的更新,reloadData 过程没有默认的动画过程
可以采用 reloadItemsAtIndexPaths方法
[self.collectionView reloadItemsAtIndexPaths:@[indexPath]]; 传入参数就是要刷新的 cell 所在的 indexPath组成的数组,但 reloadItemsAtIndexPath默认会有一个动画的过程,cell内容更新的瞬间会出现原内容与新内容重叠的情况,使用如下方式取消该动画即可 :
[UIView performWithoutAnimation:^{ [self.collectionView reloadItemsAtIndexPaths:@[indexPath]]; UITableView 的 reloadSections方法也有同样的情况 :
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone]; 转载地址:http://apgab.baihongyu.com/