Detect if a UICollectionViewCell is being displayed
-
21-12-2019 - |
Question
I have set a UICollectionView to 'Paging Enabled'. I want to be informed when a UICollectionViewCell becomes active.
It seems like the collectionView:didSelectItemAtIndexPath:
of the UICollectionViewController cannot achieve this effect: It only fires when a user explicitly select a cell, not when the cell is swiped to the front.
Each cell has a view controller associated with it. I probably can use viewDidLoad
to as a proxy of this event. But it does not sound like a clean solution.
Solution
You can use collectionView:didEndDisplayingCell:forItemAtIndexPath:
to detect that something changed and visibleCells
to know what now on screen
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow