重置UICollectionView上的滚动 [英] Reset scroll on UICollectionView
本文介绍了重置UICollectionView上的滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个水平的 UICollectionView
,它可以正常工作并滚动。当我点击一个项目时,我更新了我的数据并调用 reloadData
。这有效,新数据显示在 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?
推荐答案
您可以使用此方法滚动到您想要的任何项目:
You can use this method to scroll to any item you want:
- (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath
atScrollPosition:(UICollectionViewScrollPosition)scrollPosition
animated:(BOOL)animated
这篇关于重置UICollectionView上的滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文