http://fei263.blog.163.com/blog/static/92793724201091391949748/
数据源是个array:
NSMutableArray *items;
ViewController的这个方法返回数据条数: +1是为了显示"加载更多"的那个cell
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
int count = [items count];
return count + 1;
}
这个方法定制cell的显示, 尤其是"加载更多"的那个cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if([indexPath row] == ([items count])) {
//创建loadMoreCell
return loadMoreCell;
}
//create your data cell
return cell;
}
还要处理"加载更多"的那个cell的选择事件,触发一个方法来加载更多数据到列表
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == [items count]) {
[loadMoreCell setDisplayText:@"loading more ..."];
[loadMoreCell setAnimating:YES];