繁体   English   中英

检测UIScrollview滚动到底

[英]Detect UIScrollview scrolling past bottom

我正在尝试创建类似于Reeder的功能,如果您在滚动视图中在内容的下方或上方滚动,则会向您介绍新内容。

我以为我要通过scrollViewWillEndDragging:withVelocity:targetContentOffset到达一个好的地方:

但是,这仅停留在底部。

有什么方法可以检测到您是在滚动到底部还是顶部(垂直滚动条开始变小时)

谢谢!

发表评论作为答案:

检查scrollviewDidScrollcontentOffset ,以及当contetOffset超出底部/顶部时,将新内容添加到scrollview中,并增加内容大小

也许更好的解决方案是这样的:

-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {

    if (targetContentOffset->y == 0 && scrollView.contentOffset.y < - someOffset) { //use someOffset if you dont want to reload immedeately on scroll to top
        //dragged past top
    }

    if (targetContentOffset->y == scrollView.contentSize.height && scrollView.contentOffset.y > scrollView.contentSize.height + someOffset) { 
        //dragged past bottom
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM