I have a vertically scrolling collection view with flow layout. I have subclassed the layout object in order to align the elements to the left on each line (with code borrowed from here and there), and place the section headers on the left margin (inset) of each section (instead of above), but otherwise it's just a flow layout.
I want to force the cells for some items (not all) to be placed "on the next line", even if there is room to fit them to the right of the previously placed cell.
The only place where I can see myself doing this is when overriding the UICollectionViewFlowLayout
method layoutAttributesForItemAtIndexPath(_:)
.
However, only the delegate/data source knows which items require a new line, and none of the methods from UICollectionViewDelegate
, UICollectionViewDataSource
or UICollectionViewDelegateFlowLayout
seem to give me a chance to specify that.
What would be an elegant way of achieving this?