0
votes

I'm updating the layout of a UICollectionView by moving a cell.

collectionView.moveItem(at: sourceIndex, to: destIndex)

collectionView.collectionViewLayout.invalidateLayout()

collectionView.setCollectionViewLayout(collectionView.collectionViewLayout, animated: true)
{ (done) in
      print("i'm here")
}

But the completion block of setCollectionViewLayout is never called, while the animation is correctly done. Any idea ?

Thank you

1
And I finally found that I don't need setCollectionViewLayout because the moveItem already do the animation... - Max

1 Answers

0
votes

Edit:

BallpointBen is correct - the structure change is not needed.

I believe the reason you do not get the completion block is because you are setting the New layout to the Existing layout. So, because there is no actual change, there is no "completion".

Whoops... The structure should probably be:

    collectionView.setCollectionViewLayout(collectionView.collectionViewLayout, 
        animated: true, completion: {
            (done) in
            print("I'm here")
    })