iOS UICollectionView 和 UITableView cell更新 详解
2017-01-07 21:24
411 查看
1> 更新全部数据
UICollectionView 与 UITableView类似,都可以使用 reloadData 方法来进行所有 cell内容的更新,reloadData 过程没有默认的动画过程
2> 更新特定 cell 中的数据
UICollectionView
可以采用 reloadItemsAtIndexPaths方法
[self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
传入参数就是要刷新的 cell 所在的 indexPath组成的数组,但 reloadItemsAtIndexPath默认会有一个动画的过程,cell内容更新的瞬间会出现原内容与新内容重叠的情况,使用如下方式取消该动画即可 :
[UIView performWithoutAnimation:^{
[self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
}];
UITableView
UITableView 的 reloadSections方法也有同样的情况 :
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
UICollectionView 与 UITableView类似,都可以使用 reloadData 方法来进行所有 cell内容的更新,reloadData 过程没有默认的动画过程
2> 更新特定 cell 中的数据
UICollectionView
可以采用 reloadItemsAtIndexPaths方法
[self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
传入参数就是要刷新的 cell 所在的 indexPath组成的数组,但 reloadItemsAtIndexPath默认会有一个动画的过程,cell内容更新的瞬间会出现原内容与新内容重叠的情况,使用如下方式取消该动画即可 :
[UIView performWithoutAnimation:^{
[self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
}];
UITableView
UITableView 的 reloadSections方法也有同样的情况 :
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
相关文章推荐
- 详解iOS开发中UITableview cell 顶部空白的多种设置方法
- IOS UItableview UIcollectionview cell高度自适应
- 详解iOS开发中UITableview cell 顶部空白的多种设置方法
- iOS --- UICollectionView中使用reloadItemsAtIndexPaths进行局部cell更新
- IOS UItableview UIcollectionview cell高度自适应
- iOS Swift UICollectionView横向分页滚动,cell左右排版问题详解
- iOS 之 UITableView 使用详解/性能优化/UITableViewCell/UITableViewController
- iOS UICollectionView reloadData后找到某个cell 更新某个cell数据
- IOS UITableView详解三性能优化 Cell重用
- iOS UIcollectionView 和 UITableView 限制item 或cell的交换方法
- How to stop UITableView from clipping UITableViewCell contents in iOS 7
- iOS UITableView cell accessoryType single checkmark
- IOS之UITableView cell自定义视图中插入Tableview
- IOS控件UITableView详解
- ios tableView那些事 (十六) UITableView中Cell重用机制导致内容重复解决方法
- ios UITableView中Cell重用机制导致内容重复解决方法
- IOS 7 UITableView cell lines不能靠左解决方法
- IOS控件学习之UITableView代码实例详解
- ios uitableview 刷新某一个cell 或 section
- IOS控件UITableView详解