如何在ios中检查滚动视图是否在底部滚动

Raf*_*fay 2 cocoa-touch scroll objective-c uiscrollview ios

如何检查滚动视图是否已在 iOS 中滚动到屏幕底部?提前致谢。

2in*_*tor 5

UIScrollViewDelegate在承载 UIScrollView 的类中实现。

设置scrollView.delegate属性。

实现下面的方法。

-(void)scrollViewDidScroll: (UIScrollView*)scrollView
{
    float scrollViewHeight = scrollView.frame.size.height;
    float scrollContentSizeHeight = scrollView.contentSize.height;
    float scrollOffset = scrollView.contentOffset.y;

    if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
    {
        //This condition will be true when scrollview will reach to bottom
    }

}
Run Code Online (Sandbox Code Playgroud)