I have a UICollectionView
. I want to scroll to the bottom when the view appears. How to do this?
Can someone help me out on this?. Thanks in advance.
You can use the below code to scroll a UICollectionView
programmatically to the bottom
NSInteger section = [self numberOfSectionsInCollectionView:collectionView] - 1;
NSInteger item = [self collectionView:collectionView numberOfItemsInSection:section] - 1;
NSIndexPath *lastIndexPath = [NSIndexPath indexPathForItem:item inSection:section];
[collectionView scrollToItemAtIndexPath:lastIndexPath atScrollPosition:UICollectionViewScrollPositionBottom animated:YES];
NSIndexPath *lastItem = /*Indexpath of last item*/;
[self.collectionView scrollToItemAtIndexPath:lastItem atScrollPosition:UICollectionViewScrollPositionBottom animated:YES];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With