How do I support the fast-scrolling scrubber using UICollectionViewDiffableDataSource?

I have a UICollectionView that I feed data into using UICollectionViewDiffableDataSource. I want to display a scroll scrubber on the trailing edge of it, like I'd get if I implemented the data source methods indexTitlesForCollectionView and indexPathForIndexTitle. But the data source is the diffable data source object, and there's no property or closure on it to supply index titles as of iOS 15.

How are index titles supposed to work with UICollectionViewDiffableDataSource?

Replies

UICollectionViewDiffableDataSource conforms to the UICollectionViewDataSource protocol, so you can subclass UICollectionViewDiffableDataSource and override those optional methods to provide index titles.

  • This works to make the index titles show up, but I seemingly have no way to reload the index titles when my data changes other than reloadData, which defeats a large part of the purpose of using a diffable data source. See FB9755148 - add reloadSectionIndexTitles to UICollectionView.

Add a Comment