iPhone UITableView分页结果 [英] iPhone UITableView paginate results

查看:145
本文介绍了iPhone UITableView分页结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最好的方法是对从服务器中提取的大量结果进行分页?就服务器而言,我可以抵消并限制结果,所以我一次只能拉25个,但是什么是允许用户查看更多结果的最佳方式,而无需不断滚动增长列表,如应用程序商店app?

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?

谢谢,
Howie

thanks, Howie

推荐答案

To在列表底部添加一个新单元格,当您单击它时将获得下一个单元格,执行以下操作

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

在...中

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

如果还有更多要检索的话,请再添加1行

Add 1 extra row if there is more to retrieve

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

然后是最后一个单元格in ...

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];

然后在......

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

使用新金额执行更新tableview中项目列表所需的内容

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

这篇关于iPhone UITableView分页结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆