如何使scrollViewDidScrollToTop在UITableView中工作? [英] How can I get scrollViewDidScrollToTop to work in a UITableView?
本文介绍了如何使scrollViewDidScrollToTop在UITableView中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我认为标题说明了一切.我想在用户滚动到表格视图的顶部时得到通知.
I think the title explains it all. I want to be notified when a user scrolls to the top of a tableview.
我很幸运地尝试了以下操作,甚至还向.h文件中添加了UIScrollViewDelegate.
I've tried the following with no luck and even added a UIScrollViewDelegate to the .h file.
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView{
NSLog(@"ScrolledToTop");
}
谢谢!
编辑:如果我按状态栏,则可以调用它.但是如果我滚动到顶部,则不会.很奇怪...它可能与tableview到达顶部时弹跳有关吗?
Edit: I can get it to call if I press the status bar. But not if I scroll to the top. Weird... could it have something to do with the tableview bouncing when it reaches the top?
推荐答案
如果尝试此操作会发生什么?
What happens if you try this?
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y == 0)
NSLog(@"At the top");
}
这篇关于如何使scrollViewDidScrollToTop在UITableView中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文