3

I know that we can scroll the collection view to a specific cell with the following method:

[self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionRight animated:NO];

In my case I would like to scroll to the end of the collection view who contains a footer view. If I'm using above code, then UICollectionView is scrolled to the last element but the footer view is not visible.

Pradhyuman sinh
  • 3,938
  • 1
  • 19
  • 38
fvisticot
  • 6,499
  • 13
  • 43
  • 70

2 Answers2

1

Found this answer UIScrollView scroll to bottom programmatically, which worked perfectly for my collectionview (despite the ongoing debate on the referenced answer).

CGPoint bottomOffset = CGPointMake(0, self.collectionView.contentSize.height - self.collectionView.bounds.size.height);
        [self.collectionView setContentOffset:bottomOffset animated:YES];
Community
  • 1
  • 1
-1

Use below code:

   [YourCollectionView setContentOffset:CGPointMake(0, YourCollectionView.contentSize.height) animated:YES];
Pradhyuman sinh
  • 3,938
  • 1
  • 19
  • 38
  • 1
    The y point should be YourCollectionView.contentSize.height - YourCollectionView.frame.size.height – aytek Mar 03 '17 at 16:06