UITableView load more when scrolling to bottom like Facebook application

后端 未结 18 2185

I am developing an application that uses SQLite. I want to show a list of users (UITableView) using a paginating mechanism. Could any one please tell me how to load more dat

18条回答
  •  旧时难觅i
    2020-11-27 09:42

    I have implemented one solution that i found in stackoverflow, and it works fine, but i think the shinyuX's solution it's very easy to implement and works fine for my propose. If someone wants a different solution can use this one below.

    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    
       // UITableView only moves in one direction, y axis
        CGFloat currentOffset = scrollView.contentOffset.y;
        CGFloat maximumOffset = scrollView.contentSize.height - scrollView.frame.size.height;
    
        //NSInteger result = maximumOffset - currentOffset;
    
        // Change 10.0 to adjust the distance from bottom
        if (maximumOffset - currentOffset <= 10.0) {
            [self loadOneMorePage];
            //[self methodThatAddsDataAndReloadsTableView];
        }
    }
    

提交回复
热议问题