清空UICollectionView中的所有单元格 [英] Empty all cells from UICollectionView

查看:684
本文介绍了清空UICollectionView中的所有单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用iOS6的真棒新的 UICollectionView 如何在大循环中删除所有 UICollectionViewCell 对象?

Using iOS6's awesome new UICollectionView how am I able to delete all of the UICollectionViewCell objects in a big loop?

假设我已将所有数据加载到其中,我点击刷新,我想删除当前所有内容,然后再次调用我的内容。

Say I've loaded all my data into it already, I hit refresh, I want to delete everything currently in there, then just call my stuff again.

我找到 deleteItemsAtIndexPaths ,它需要 NSArray ,所以如何我可以把所有物品都装进去吗?

I've found deleteItemsAtIndexPaths which takes an NSArray, so how can I get all items into it?

推荐答案

原来我可以使用 deleteSections 并传递 NSIndexSet 通过它,得到 0,0 的范围,它将删除唯一的部分。

Turns out I can use deleteSections and pass a NSIndexSet through to it, making a range of 0,0 and it'll delete the one and only section.

NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 0)];
[self.collectionView deleteSections:indexSet];

我可能只是使用 indexSetWithIndex 但是当我的应用程序崩溃了。

I could probably just use indexSetWithIndex but when I did my app crashed.

这篇关于清空UICollectionView中的所有单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆