UITableView -> How to load additional entry on scroll down?

Go To StackoverFlow.com

5

I want to load my data on scroll down for my tableView.

I have a JSON API from where I get my data. Its a Private Message System. Everytime I will get 20 entries, I can select a page (0 to x) get the first to x entries (everytime 20 entries). So at the moment I have my table and I load a list of 20 entries and show them.

Now I want to have as soon as I reach the last entry it should load the next 20 entries.

I try to read many things about it here on StakcOVerflow and look at a Github Project with this but don't understand it at all. Can someone tell me how to do this?

2012-04-04 08:05
by Kovu


9

You can use the willDisplayCell method of UITableview. For ex, to see whether a row has 'load-more' button if you have one.

See this post.

A Github project.

2012-04-04 08:21
by Vignesh
Your last link no longer works. Do you know where a valid one is - Aza 2013-04-29 06:12
@Telthien. The link is removed. will update with some other soon - Vignesh 2013-04-29 10:42


3

you can implement this delegate

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
//put data on your array
[tableView reloadData];
}

2012-04-04 08:44
by touti
This approach is not good because on reloadData, the very same willDisplayCell: will be called and so on and so on - Marcin 2015-05-05 10:08
willDisplayCell will be called only when new cells will apear , not for visible one - touti 2015-05-05 15:50
Ads