Display records of next page in json in uitableview on scrolling the tableView when I reach the last record

微笑、不失礼 提交于 2019-12-04 22:01:24

Have you tried using ‘page’ parameter in your query? http://api.worldbank.org/countries/all/indicators/SP.POP.TOTL?format=json&page=2

If you want to list all records, you can use ‘per_page’ parameter, which I would not recommend http://api.worldbank.org/countries/all/indicators/SP.POP.TOTL?format=json&per_page=13640

You can set some tag on your last cell and then send call to the server once you reach to that cell. Once you received data from server append it to your table view data and reload the data.

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mycell"];
    if(indexPath.row == [data count])
    {

        cell.tag = SOME_TAG_OF_LAST_CELL;
    }

    return cell;
}


- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(cell.tag == SOME_TAG_OF_LAST_CELL)
    {
        // send call to server to fetch next page from server.
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!