有人知道如何在显示集合视图时重新加载/刷新UICollectionView吗?基本上,我正在寻找类似于UITableview的标准reloadData方法的东西。
发布于 2013-02-07 09:58:58
你可以直接拨打:
[self.myCollectionView reloadData];还可以重新加载各个部分和项目:
[self.myCollectionView reloadSections:indexSet];
[self.myCollectionView reloadItemsAtIndexPaths:arrayOfIndexPaths];发布于 2013-12-22 05:49:00
[self.collectionView reloadData];发布于 2016-11-11 19:47:26
正确且最好的方法是使用
NSMutableArray *indexPaths = [NSMutableArray array];
//prepare some data
//batchupdate as block
[self.collectionView performBatchUpdates:^{
//operations like delete
[self.collectionView deleteSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, count)]];
[self.collectionView insertItemsAtIndexPaths:indexPaths];
} completion:^(BOOL finished) {
// call something when ready
}
}];所有这些都会被预先计算出一个很好的动画。最佳实践是先删除然后再添加所有元素,以避免冲突。
https://stackoverflow.com/questions/14742106
复制相似问题