2

My collectionView presents 20 items in landscape mode. In portrait mode, I only want 8 reusable items presented. How can I achieve this?

When does the collectionView call collectionView:numberOfItemsInSection: on the data source in order to update itself???

DanMoore
  • 621
  • 1
  • 8
  • 14

1 Answers1

8

You need to force the application to change layout of the collection view when changing orientation:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                               duration:(NSTimeInterval)duration{

    [self.myCollectionView.collectionViewLayout invalidateLayout];
}

See this thread: UICollectionView Set number of columns

Good luck!

Community
  • 1
  • 1
Joakim Serholt
  • 403
  • 5
  • 17
  • `-[willRotateToInterfaceOrientation:duration:]` is deprecated on iOS 8, any other alternative for this? – rraallvv Aug 22 '15 at 14:02
  • The Apple Docs suggest: `Deprecated:Use viewWillTransitionToSize:withTransitionCoordinator: to make interface-based adjustments.` – donmarkusi Jan 28 '16 at 10:29