Question

I have a UICollectionView which uses UICollectionViewDelegateFlowLayout. I've added a method which changes the layout when tapping a cell setCollectionViewLayout.

All the cells have a text label with text and I would like to empty all the text labels on every cell when changing the layout. What's the best way to accomplish that?

Thanks,

Was it helpful?

Solution

I would imagine the simplest way is just to call reloadData on your collection view at the same time that you change the layout (and have a conditional in your cellForItem data source method that empties the text labels upon each layout change).

Alternatively, you could have your UICollectionViewCells keep track of the layout they're currently displayed in, and adjust their views accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top