How to handle UICollectionView reloadData with selected index path

Issue #434

When calling collectionView.reloadData(), selected indexpath stays the same, but be aware that order of data may have changed

let selectedData = ...
let indexPathForSelectedData = ...

collectionView.scrollToItem(
    at: indexPathForSelectedData,
    at: .centeredHorizontally,
    animated: false
)
Written by

I’m open source contributor, writer, speaker and product maker.

Start the conversation