问题描述
UIScrollViewDelegate有两个委托方法 scrollViewDidScroll:
和 scrollViewDidEndScrollingAnimation:
但这些都没有告诉你什么时候滚动完成。 scrollViewDidScroll
仅通知您滚动视图滚动而不是滚动完成。
UIScrollViewDelegate has got two delegate methods scrollViewDidScroll:
and scrollViewDidEndScrollingAnimation:
but neither of these tell you when scrolling has completed. scrollViewDidScroll
only notifies you that the scroll view did scroll not that it has finished scrolling.
另一种方法 scrollViewDidEndScrollingAnimation
如果您以编程方式移动滚动视图而不是用户滚动,则似乎只会触发。
The other method scrollViewDidEndScrollingAnimation
only seems to fire if you programmatically move the scroll view not if the user scrolls.
有没有人知道方案是滚动视图何时完成滚动检测?
Does anyone know of scheme to detect when a scroll view has completed scrolling?
推荐答案
您正在寻找的方法是 scrollViewDidEndDragging: willDecelerate:
和 scrollViewDidEndDecelerating:
。在用户抬起手指后,始终会调用第一个。如果它们滚动得足够快以导致减速, willDecelerate
将是 YES
,减速完成后将调用第二种方法。
The methods you're looking for are scrollViewDidEndDragging:willDecelerate:
and scrollViewDidEndDecelerating:
. The first one is always called after the user lifts their finger. If they scrolled fast enough to result in deceleration, willDecelerate
will be YES
and the second method will be called after deceleration completes.
()
这篇关于如何检测UIScrollView何时完成滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!