Ios – 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.

Best Solution

Delegate method: collectionView:didEndDisplayingCell:forItemAtIndexPath:

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