I have a collectionView which uses UICollectionViewCompositionalLayout. It has 150 Sections and each section can have a random number of items (up to 30) depending what comes back from the API.
I’ve been trying to lazy load each section using the prefetch API – specifically collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]).
I’m reloading each section once the data is received using collectionView.reloadSections(at: [...]) but when I scroll up and down whilst each section is loading, it’s very choppy and slow. I’ve also dispatched the reload on the main thread and have tried using OperationQueue.
I’ve also even tried using the DiffableDataSource API but its still slow.
What is the correct way to reload sections, when scrolling and lazy loading, whilst maintaining a smooth scroll experience?




