UICollectionView index title API should provide the same features as UITableView index title API

Originator:defagos
Number:rdar://FB9524467 Date Originated:Aug 17, 2021
Status:Open Resolved:
Product:UIKit Product Version:14+
Classification:Suggestion Reproducible:
 
Thank you very much in advance for considering this improvement, which would help in replacing table views with collection views in a wider range of contexts.

Summary
--------

i(Pad)OS 14 introduces `UICollectionLayoutList`, making `UICollectionView` even more relevant as a replacement for `UITableView`. 

This same OS version also introduced two data source methods to support an index title bar for `UICollectionView`, likely to accomodate more use cases previously covered by table views (e.g. contact lists):

- `indexTitles(for:)`
- `collectionView(_:indexPathForIndexTitle:at:)`

This index support for `UICollectionView` was probably an extension of the tvOS collection view index support, which was added in tvOS 10.2. Compared to `UITableView` index title support, though, the i(Pad)OS API is lacking a few methods and properties, detailed below.


Specifications
--------------

The i(Pad)OS collection view index title API is lacking several methods in comparison to the table view API. One of them is required, other ones are useful for customization purposes.

1. Required

A `reloadSectionIndexTitles:` method asking the collection view to reload the index list from its data source is required. Please refer to `UITableView` corresponding documentation for more information.

This method is needed when the index title list is not known initially, e.g. if the index is built from results loaded from an asynchronous network request. In such cases we need a way to ask the collection view to reload the index list from its asynchronously updated data source source. This is currently not possible.

Remark: The fact this API was not initially made available for tvOS collections was not a problem, which probably explains why it is still missing on i(Pad)OS. On tvOS the index bar is namely lazily loaded when scrolling fast (the data source is checked when the index bar appears), making a `reloadSectionIndexTitles` method less useful.

2. Optional but still useful

The following customization properties could be useful:

- `sectionIndexMinimumDisplayRowCount`
- `sectionIndexColor`
- `sectionIndexBackgroundColor`
- `sectionIndexTrackingBackgroundColor`

Please refer to the corresponding `UITableView` documentation for more information.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!