如何阻止UIScrollView到达底部时滚动

cdu*_*dub 2 objective-c uiscrollview ios setcontentview ios8

我有以下代码来获取UIScrollView到达其内容视图结束时的事件:

- (void) scrollViewDidEndDecelerating:(UIScrollView *) scrollView
{
    float currentEndPoint = scrollView.contentOffset.y + scrollView.frame.size.height;

    // CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height - scrollView.bounds.size.height);
    // [scrollView setContentOffset:bottomOffset animated:NO];

    if (currentEndPoint >= scrollView.contentSize.height)
    {
        // We are at the bottom
Run Code Online (Sandbox Code Playgroud)

我注意到当我滚动到底部时它会撞到它并反弹回来.

如果我添加这个:

CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height - scrollView.bounds.size.height);
[scrollView setContentOffset:bottomOffset animated:NO];
Run Code Online (Sandbox Code Playgroud)

然后滚动回到底部.

是否有任何方法让它保持在底部没有"反弹",因为一旦它击中底部,阻止它移动.

谢谢.

小智 5

您应该取消选中scrollview的bounce属性.检查截图!

在此输入图像描述