列表的一半将在开始时加载,当到达列表的末尾时,另一半将添加到表视图内的下方
我有一个 tableView 和 json 数据。我希望 tableview 加载一半的 json 数据。当表视图滚动到前半部分结束时,另一半将被加载。有人知道我该怎么做吗?
I have a tableView and json data.I want tableview load half in json data. When table view scroll comes to the end of the first half , the other half will be load.Can anyone know how I can ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您必须在
scrollViewDidScroll
的帮助下进行一些pagination
类型的处理,以观察何时到达 tableview 的末尾以加载下一批首先设置一些初始变量来帮助您跟踪分页过程。
我创建了这个加载函数,它有助于批量添加项目并适当地重新加载表格视图
然后观察是否使用
scrollViewDidScroll
到达末尾并重新加载表格视图以显示插入的行如下所示:
如果您发现某些部分难以理解或添加到您自己的代码中,可以找到可以按原样运行的完整代码 此处:
I believe you will have to do some
pagination
type of processing on your side with the help ofscrollViewDidScroll
to observe when you reach the end of a the tableview to load the next batchStart by setting some initial variables to help you track the paging process.
I create this loading function which helps with adding the items in batches and reloading the tableview appropriately
Then observe if you reached the end using
scrollViewDidScroll
and reload the tableview to show the inserted rowsHere is how that will look:
If you found some part difficult to follow or add into your own code, the complete code which can run as is can be found here: