I have a collection view where the cells contain UIImageView
s, 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.
Ios – How to tell when a UICollectionViewCell disappears
cocoa-touchiosuicollectionviewuicollectionviewcell
Related Question
- Ios – How to sort an NSMutableArray with custom objects in it
- Ios – How to check for an active Internet connection on iOS or macOS
- Ios – How to make a UITextField move up when the keyboard is present – on starting to edit
- Ios – Xcode – How to fix ‘NSUnknownKeyException’, reason: … this class is not key value coding-compliant for the key X” error
- Ios – In a storyboard, how to make a custom cell for use with multiple controllers
- Objective-c – Resize UICollectionView cells after their data has been set
Best Solution
Delegate method:
collectionView:didEndDisplayingCell:forItemAtIndexPath:
But you should probably just create a custom cell and reuse instead of creating and destroying...