一般上拉加载数据都是上拉以后在请求,最为一个轻微强迫症患者觉得不爽,发现网易新闻就是一边上拉一边加载,就想着试一下。

开始想用scrollView的代理 发现不怎么好用 后来查了下tableView的一个代理方法也能做到,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    
    //获取当前行数
    NSInteger row = [indexPath row];
    
    //判断下当前行数和当前总数据数 -1 代表想在倒数第几行开始请求
    if (row == _dataListArray.count - 1) {
        
        //请求上拉数据
        if (!_isLastData) {
            [self.tableView.footer beginRefreshing];
        }
    }
}

谢谢这位的博客:http://blog.csdn.net/xiaobo16/article/details/38511221