I want to make a left-aligned self-sizing collectionView just like this one:
and here is my sample project: https://github.com/DiaobaoMiaoo/LeftAlignedSelfSizingCollectionView
After running the project, rotate the device from portrait to landscape, then press the red button. Then the app will crash seemingly from layoutAttributesForElements
with log:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
Any idea what is the cause and how to fix this issue? Thanks!
I have also tried other approaches I found online to achieve the left aligned CollectionView including:
Left Align Cells in UICollectionView
https://github.com/mokagio/UICollectionViewLeftAlignedLayout
https://github.com/mischa-hildebrand/AlignedCollectionViewFlowLayout
But they all share the same issue that if the content of the cell is much longer than collectionView.framce.width, then the app will freeze with the console spammed on iOS11.