Search code examples
iphoneobjective-cipadios6uicollectionview

Reset scroll on UICollectionView


I have a horizontal UICollectionView which works fine and scrolls. When I tap an item I update my data and call reloadData. This works and the new data is displayed in the UICollectionView. The problem is the scroll position doesn't change and it is still viewing the last place. I want to reset the scrolling to the top (Or left in my case). How can I do this?


Solution

  • You can use this method to scroll to any item you want:

    - (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath 
                   atScrollPosition:(UICollectionViewScrollPosition)scrollPosition 
                           animated:(BOOL)animated