0

I've got an idea for a collection view that keep the items centred when there is only a few item, then falls back to a traditional vertical flow. Here's how I picture it expanding as I need more items.

Example

1. Is this acumblisable with a generic UICollectionViewFlowLayout?

2. If not have you got any advice on how to do this with a custom layout?

Benjamin
  • 663
  • 8
  • 23

1 Answers1

-1

A idea could be to manage your model to be able to put empty UICollectionViewCell where you want.

For example:

- (void)setMyModel:(NSArray*)array
{
    NSMutableArray myNewModel = [NSMutableArray array];

    if (array.count < 5){
        [self addEmptyLine:myNewModel]
    }
    int nbOfLine = (int)(array.count / 5);
    int nbOfCellLastLine = ((array.count / 5) - nbOfLine)*5;

    // add nbOfLine * 5 object in your array

    // add your last line
    [self addLineWithNbOfCell:nbOfCellLastLine andArray:array];
}

It's just a quick idea but that could work.

Nicolas Bonnet
  • 1,275
  • 11
  • 15
  • I was thinking of doing something like this but I don't like the idea of having 'blanks' in my model. I would like to try and keep a separation. – Benjamin Feb 23 '14 at 21:27