I am trying to display a UICollectionView
capable of displaying a user's photo library where the photo aspect ratio is respected (constrained by the width of the device - think the instagram full width feed view).
I have used examples from UICollectionView Self Sizing Cells with Auto Layout and https://medium.com/@wasinwiwongsak/uicollectionview-with-autosizing-cell-using-autolayout-in-ios-9-10-84ab5cdf35a2 (there is a PR in the repo linked in the article to update the project for iOS 12 FYI) to setup a UICollectionView
with variable height cells, but all of these are super laggy/terrible to use when there are a large amount of cells in the view.
For example, the sample app (with iOS 12 fix) here: https://github.com/tttsunny/CollectionViewAutoSizingTest/pull/5 works great with 100 cells, but if you try to display 30,000 then the app is unusable - it gets stuck scrolling and is not responsive. The latency is in the estimated size logic of the UIViewController
.
Is using an estimated size not recommended for large size UICollectionView
objects? What can I do to get the cells to have different height values then?