views:

267

answers:

1

What us the best way to paginate a large number of results that are being pulled from a sever? As far as the server goes, I can offset and limit the results so I'm only pulling maybe 25 at a time, but what's the best way to allow a user to view more results without constantly scrolling down a growing list like the app store app?

thanks, Howie

+1  A: 

To add a new cell at the bottom of your list that will get the next set when you click it, do the following

In the ...

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

Add 1 extra row if there is more to retrieve

  return totalCount > [list count]?[list count]+1:[list count]

Then for the last cell in ...

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

create the 'Load more' cell if it's required

[[NSBundle mainBundle] loadNibNamed:@"LoadMoreCell" owner:self options:nil];
LoadMoreCell *cell = loadMoreCell;
NSString *loadMore = [NSString string with Format:@"Load %d more...", numberToLoad];

Then in ...

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

do what is required to update the list of items in the tableview with the new amount

Liam
Thanks for the feedback. I was actually looking for an alternative solution so the tableview doesn't have to keep growing.
Ward