使用iOS6的超酷UICollectionView
我如何才能在大循环中删除所有UICollectionViewCell
对象?假设我已经将所有的数据加载到它中,我点击刷新,我想删除当前内容,然后再次调用我的东西。清空UICollectionView中的所有单元格
我发现deleteItemsAtIndexPaths
需要NSArray
,所以我怎样才能把所有物品都放进去呢?
使用iOS6的超酷UICollectionView
我如何才能在大循环中删除所有UICollectionViewCell
对象?假设我已经将所有的数据加载到它中,我点击刷新,我想删除当前内容,然后再次调用我的东西。清空UICollectionView中的所有单元格
我发现deleteItemsAtIndexPaths
需要NSArray
,所以我怎样才能把所有物品都放进去呢?
原来我可以使用deleteSections
并将NSIndexSet
传递给它,使得范围为0,0
,它将删除唯一的部分。
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 0)];
[self.collectionView deleteSections:indexSet];
我可能只是使用indexSetWithIndex
,但当我做我的应用程序崩溃。
清除UICollectionVew的正确方法是简单地清除数据源,然后重新加载收集视图。
所以,如果您的数据源是一个数组:
self.dataArray = nil;
[self.collectionView reloadData];
繁荣,你清理出去。
为什么indexSetWithIndex:0崩溃?我遇到这个,不知道为什么 – Wingzero