您将按UIScrollViewDelegate
如下方式实现协议方法:
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (!decelerate) {
[self scrollingFinish];
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[self scrollingFinish];
}
- (void)scrollingFinish {
//enter code here
}
斯威夫特版本
public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if decelerate {
scrollingFinished()
}
}
public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
scrollingFinished()
}
func scrollingFinished() {
print("scrolling finished...")
}
对于上述委托方法,The scroll view sends this message when the user’s finger touches up after dragging content. The decelerating property of UIScrollView controls deceleration.
当视图减速停止时,参数decelerate
将为NO
.
第二个用于缓慢滚动,甚至当您的手指触摸时滚动停止,正如 Apple Documents 所说,when the scrolling movement comes to a halt
.