从可重用的Cell中出列时,自定义CollectionViewCell会触发什么方法?

时间:2013-01-09 20:20:36

标签: ios uicollectionviewcell reuseidentifier

我像往常一样使用其父ViewController

中的方法将可重复使用的自定义ItemCollectionViewCell出列
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    ItemCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
}

但在我的ItemCollectionViewCell上,我实现了方法initWithFrame,该方法最初只会被调用,但不会在单元格出列重新使用时被调用。

在父视图控制器上调用ItemCollectionView之后重新添加到队列之前,在[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath]内触发的方法是什么?

1 个答案:

答案 0 :(得分:7)

-[UICollectionReusableView prepareForReuse]是方法。 Here是该方法的文档。