I'm trying to display a list of items in a UICollectionView. I have multiple 
sections for these items and a fixed cell width but dynamic height. I'm using 
the standard flow layout. The items are layed out in three columns by setting 
the estimated item size and auto-layout constraints. My collection view 
delegate/data source is extremely basic: I implement 
numberOfSectionsInCollectionView, numberOfItemsInSection, and 
cellForItemAtIndexPath with almost nothing except the bare minimum. I return a 
fixed number of sections and a variable number of items in each section based 
on a data model. cellForItemAtIndexPath dequeues one cell type and changes the 
text on two labels in the cell.

Now the funniness: When there is more than one item in a section, the cells 
fill in the space from left to right, flowing across multiple lines as needed. 
However, if there is one item in a section, it lays out that cell in the center 
of the collection view. This looks really weird and breaks up the flow.

Here is an ascii rendering of what this looks like:

-----------------------------------------------------
|                                                           |
|  Section 1                                           |
|  [cell 0]----------[cell 1]-----------[cell 2]  |
|  [cell 3]                                               |
|                                                           |
|  Section 2                                           |
| ------------------- [cell 0]----------------------|
|                                                           |
|  Section 3                                           |
|  [cell 0]----------[cell 1]--------------------- |
|                                                           |
| Section 4                                            |
| ------------------- [cell 0]----------------------|
|                                                           |
-----------------------------------------------------

Notice in section 2 and 4, the only cell is layed out in the middle of the 
collection view, while the cells in the other sections flow from left to right.

Any ideas on how to make the single item section flow from left to right rather 
than centered?

Thanks.

Doug Hill
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to