问题检测是否UITableView已滚动到底部 [英] Problem detecting if UITableView has scrolled to the bottom

查看:83
本文介绍了问题检测是否UITableView已滚动到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码来检测是否到达UITableView的底部

I'm using the following code to detect if I've reached the bottom of a UITableView

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ 
    if(self.tableView.contentOffset.y >= (self.tableView.contentSize.height - self.tableView.bounds.size.height)) {
        NSLog(@"bottom!");
        NSLog(@"%@", [self getLastMessageID]);
        [self getMoreStuff:[self getLastMessageID]];
    }

}

问题是当用户正在拉下tableview(像pull刷新)代码触发。如何处理?

This works fine, but the only problem is when the user is pulling the tableview down (like pull to refresh) the code fires. How can I handle this?

推荐答案

尝试这种方式

    if(self.tableview.contentOffset.y<0){
              //it means table view is pulled down like refresh
              return;
            }
else if(self.tableView.contentOffset.y >= (self.tableView.contentSize.height - self.tableView.bounds.size.height)) {
        NSLog(@"bottom!");
        NSLog(@"%@", [self getLastMessageID]);
        [self getMoreStuff:[self getLastMessageID]];
    }

这篇关于问题检测是否UITableView已滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆