Reputation: 380
I have a UICollectionView
with several cells – there are always some of them outside the viewport, so there are cells being reused.
When an event occurs I want to take a specific cell and move it to the front of the UICollectionView
. In order to make moveItemAtIndexPath()
work I need to know the current indexPath
of the Cell that I want to move.
When I initialize the Cells in the CollectionViewDelegate
with the cellForItemAtIndexPath
method I save its indexPath
into a variable of the Object that is the model of the Cell (not it’s actual Object, just the model). Then I look at this variable when I want to move the cell.
This is working fine as long as the cell was visible once – it seems like it only initiated then, even though it is part of the CollectionViewData
all the time.
How can I make sure my CollectionViewCell
has an indexPath
, even when it is not visible or has not been visible yet?
Upvotes: 2
Views: 1123
Reputation: 3302
If you know what data (cell) you want to present at the front (I assume top) of your UICollectionView
, why don't you just update your dataSource
and reload your UICollectionView
?
Upvotes: 1