Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell when a UICollectionViewCell disappears

I have a collection view where the cells contain UIImageViews, and I'm trying out adding a label as a subview to these views. The problem is that since the cells are reusable, labels keep getting added. I can, of course, check whether my label already exists and reuse it, but I'd really like to clean up after myself. Is there a way to tell when the cell disappears and remove the label then? I've looked at the various docs and don't find any methods that seem promising. Maybe I'm just missing it.

like image 380
Victor Engel Avatar asked Oct 28 '13 20:10

Victor Engel


1 Answers

Delegate method: collectionView:didEndDisplayingCell:forItemAtIndexPath:

But you should probably just create a custom cell and reuse instead of creating and destroying...

like image 129
Wain Avatar answered Oct 23 '22 03:10

Wain