Currently I have a standard UICollectionViewFlowLayout
scrolling horizontally, but it stack items onto each other, if the height allows.
Instead I want to have a collection view that scrolls horizontally and does no line breaking, i.e. does not stack items onto each other - simply a linear flow.
This problem is even simpler than in this question, because vertical scrolling is not required. Therefore the answer there does not apply.
I think I could subclass UICollectionViewFlowLayout
, but I am not sure which methods had to be overwritten.
I checked that currently -layoutAttributesForElementsInRect:
is called before the items are displayed (but not -layoutAttributesForItemAtIndexPath:
).
The NSArray
returned by -layoutAttributesForElementsInRect:
contains for every item a frame (some of them are stacked onto each other).
I can suppress this stacking in -collectionView:layout:sizeForItemAtIndexPath:
, if I increase in this method the height of all items to be greater than half the maximum height, but then the items itself are scaled vertically, which I don't want.
So my question is: What and how do I overwrite methods of UICollectionViewFlowLayout
or UICollectionViewLayout
to get this linear flow?