UICollectionView:如何检测滚动何时停止 [英] UICollectionView: how to detect when scrolling has stopped
问题描述
我正在使用 UICollectionView
快速滚动显示一组缩略图。滚动结束后,我想显示当前缩略图的更大的高分辨率版本。
I'm using a UICollectionView
to scroll through a set of thumbnails quickly. Once scrolling ends, I'd like to display a larger hi-res version of the current thumbnail.
如何检测用户何时完成滚动?我实现了 didEndDisplayingCell
,但这只能告诉我特定单元格何时滚动;当滚动动作实际完成时它没有告诉我。
How can I detect when the user has completed scrolling? I do implement didEndDisplayingCell
, but that only tells me when a particular cell has scrolled off; it doesn't tell me when the scroll motion actually completes.
推荐答案
NS_CLASS_AVAILABLE_IOS(6_0) @interface UICollectionView : UIScrollView
UICollectionView
是 UIScrollView
的子类。因此,如果您设置了委托并实现了 UIScrollViewDelegate
,那么您应该能够以与 UIScrollView
相同的方式检测到它。
UICollectionView
is a subclass of UIScrollView
. So if you have set the delegate and implemented UIScrollViewDelegate
, you should be able to detect this the same way as UIScrollView
.
例如: -
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
根据 documentation ,上面的方法应该告诉滚动视图何时结束减慢滚动动作。
As per documentation, the above method should tell when the scroll view has ended decelerating the scrolling movement.
这篇关于UICollectionView:如何检测滚动何时停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!