UIScrollView, reaching the bottom of the scroll view

后端 未结 7 1617
暗喜
暗喜 2020-12-07 16:05

I know the Apple documentation has the following delegate method:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;      // called when scroll         


        
7条回答
  •  无人及你
    2020-12-07 16:45

    The accepted answer works only if the bottom contentInset value is non-negative. A slight evolution would consider the bottom of the contentInset regardless of it's sign:

    CGFloat bottomInset = scrollView.contentInset.bottom;
    CGFloat bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height - bottomInset;
    if (bottomEdge == scrollView.contentSize.height) {
        // Scroll view is scrolled to bottom
    }
    

提交回复
热议问题