简体   繁体   English

UITableView -> 如何在向下滚动时加载附加条目?

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

I want to load my data on scroll down for my tableView.我想在向下滚动时为我的 tableView 加载我的数据。

I have a JSON API from where I get my data.我有一个 JSON API 从我获取数据的地方。 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).每次我会得到 20 个条目,我可以 select 页(0 到 x)得到第一个到 x 个条目(每次 20 个条目)。 So at the moment I have my table and I load a list of 20 entries and show them.所以现在我有我的表,我加载了一个包含 20 个条目的列表并显示它们。

Now I want to have as soon as I reach the last entry it should load the next 20 entries.现在我想在到达最后一个条目时立即加载接下来的 20 个条目。

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.我试着在 StakcOVerflow 上阅读很多关于它的东西,并用它查看一个 Github 项目,但根本不理解它。 Can someone tell me how to do this?有人可以告诉我该怎么做吗?

You can use the willDisplayCell method of UITableview. For ex, to see whether a row has 'load-more' button if you have one.您可以使用 UITableview 的willDisplayCell方法。例如,查看一行是否有“加载更多”按钮(如果有)。

See this post.看到这篇文章。

A Github project.一个Github项目。

you can implement this delegate你可以实现这个委托

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM