UIScrollView,到达滚动视图的底部 [英] UIScrollView, reaching the bottom of the scroll view

查看:100
本文介绍了UIScrollView,到达滚动视图的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Apple文档有以下委托方法:

I know the Apple documentation has the following delegate method:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;      // called when scroll view grinds to a halt

然而,这并不一定意味着你在底端。因为如果您使用手指,滚动一下,然后它减速,但您实际上并不在滚动视图的底部,然后它仍然被调用。我基本上想要一个箭头来显示我的滚动视图中有更多数据,然后当你在底部时消失(比如当它反弹时)。谢谢。

However, it doesn't necessarily mean you are at the bottom. Cause if you use your finger, scroll a bit, then it decelerates, but you are not actually at the bottom of your scroll view, then it still gets called. I basically want an arrow to show that there is more data in my scroll view, and then disappear when you are at the bottom (like when it bounces). Thanks.

推荐答案

我认为您可以做的是检查您的 contentOffset point位于 contentSize 的底部。所以你可能会做类似的事情:

I think what you might be able to do is to check that your contentOffset point is at the bottom of contentSize. So you could probably do something like:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    float bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height;
    if (bottomEdge >= scrollView.contentSize.height) {
        // we are at the end
    }
}

当用户向上滚动时,你可能还需要一个负面的案例来显示你的指标。您可能还想添加一些填充,例如,当用户靠近底部时,您可以隐藏指示符,但不完全位于底部。

You'll likely also need a negative case there to show your indicator when the user scrolls back up. You might also want to add some padding to that so, for example, you could hide the indicator when the user is near the bottom, but not exactly at the bottom.

这篇关于UIScrollView,到达滚动视图的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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