如何检测 UIScrollView 何时完成滚动 [英] How to detect when a UIScrollView has finished scrolling

查看:32
本文介绍了如何检测 UIScrollView 何时完成滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?

推荐答案

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    [self stoppedScrolling];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    if (!decelerate) {
        [self stoppedScrolling];
    }
}

- (void)stoppedScrolling {
    // ...
}

这篇关于如何检测 UIScrollView 何时完成滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆