Post not yet marked as solved
Post marked as unsolved with 0 replies, 294 views
I spoke to an Apple Engineer at WWDC 2021 about how to implement an EPG (Electronic Program Guide, see image below) in a collectionView.
I was recommended to use a UICollectionViewCompositionalLayout where each program corresponds to an Item and each channel corresponds to a Section (the section being provided by a SectionProvider). Furthermore, I was told to override preferredLayoutAttributesFitting to set the size of each cell.
However, I have two difficult issues that I have not been able to come around:
I cannot figure out how to ensure the CollectionView displays all cells correctly at the right spot, such that the time is aligned vertically for all channels. I am using NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .estimated(estimatedWidth), heightDimension: .fractionalHeight(1))), which provides an estimated width, but this estimated width is apparently used for all cells not in the view, causing the cells to be rendered at the wrong spot as soon as I scroll to the right.
The performance when scrolling is terrible, probably due to my overriding of preferredLayoutAttributesFitting on the cell, which causes the cell to change its width.
I was instructed not to use "self sizing cells" as this would cause performance problems. But I cannot figure a way out of this.
How do I tell the CollectionView how to render the cells at the proper spot and at the same time avoid "self sizing cells"?
Any help would be highly appreciated!