滚动到底部时如何为表格视图实现更多加载?(即拉起刷新) [英] how to implement loading more for table view when scroll to bottom?(i.e. pull up to refresh)

查看:94
本文介绍了滚动到底部时如何为表格视图实现更多加载?(即拉起刷新)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当视图滚动到底部时,我想加载更多数据,即拉动刷新,但我不知道如何显示"Loading More ..."之类的字样,如下所示,并在该单元格处停止tableview,因为如果使用

I want to load more data when view scroll to bottom,i.e. pull up to refresh, but I don't know how to display words like "Loading More..." as showing below and stop the tableview at that cell, because if use

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:10 inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];

有错误:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '-[TNTableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (10) beyond bounds (0) for section (0).'

并且如果tableView没有数据,则加载更多内容仍在底部单元格中,例如一个表格可以显示9行,如果没有用于表格视图的数据,则正在加载更多"单元格位于第10行.

and if there's no data for tableView, loading more is still at the bottom cell, e.g. a table can show 9 rows, if there's no data for tableview, the "Loading More" cell is at the 10th row.

推荐答案

我在AppCoda网站上找到了一个很好的例子,尝试在您的应用程序中使用它.

I found a great example in AppCoda website, try to use it in your app.

http://www.appcoda.com/pull-to-refresh-uitableview-empty/

我已经在我的应用程序中使用过,它确实起作用了……这可能正是您想要的.

I've used in my app and it really worked... and it is probably what you are looking for.

这篇关于滚动到底部时如何为表格视图实现更多加载?(即拉起刷新)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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