3

I have a collection view and it has a number of cells in it. I want the user to be able to flick the screen left or right to show a new set of cells. I am trying to get something very similar to the iPhone main screen when you can page between sets of apps.

I have enabled paging and if the scrolling is set to Vertical it all works fine and the user can gesture up and down for the paging to move to next page (not quite like the iPhone but good enough, it does not force whole pages seems to share a row between pages).

The problem is I want it to be that the user swipes left or right but if I put in Horizontal as the scroll direction the cells stop being draw from left to right then next row to being top to bottom and then next column.

I can find very little out there about paging at all, does anyone have any clues or can point me to a good tutorial?

Using Storyboard to try and set this up.

EDIT Or how can I change the order in which the cells are displayed, i.e. Horizontal scrolling but ordered (pipes are a page break);

1 2 3 | 7 8 9

4 5 6 | A B C

They currently come out as

1 3 5 | 7 9 B

2 4 6 | 8 A C

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Recycled Steel
  • 2,272
  • 3
  • 30
  • 35
  • Check that when it's vertical the cell index is (row,section), when it's horizontal it should be (section,row) – Lirik Jul 25 '13 at 15:56

1 Answers1

0

You can override the method

- (UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

so that, for example, for indexPath.item corresponding to the item number 3 (looking at your example because normally counting starts at 0), you will return the cell object adequate to the data object number 5 from your collection of fetched elements or other array of objects.

konrad.bajtyngier
  • 1,786
  • 12
  • 13
  • Yep that would work, it would mean I would have to do some blank cells so if the was only 3 items, it would go 1, blank, 2, blank, 3. I will think about that as it will work (bit of a pain with the display sizes as this view changes with that with extra row). Will update... Thanks – Recycled Steel Jul 26 '13 at 09:34
  • I have also been looking at UICollectionViewLayout but I am struggling to figure it out, found this http://damir.me/posts/implementing-uicollectionview-layout but still not sure it will do what I want. – Recycled Steel Jul 26 '13 at 10:06