ios - 我无法在我的 UITableView 中加载超过 40 个 UITableViewCells

标签 ios uitableview pagination

我正在解析 XML,它使用 PHP - LIMIT 和 GET 获取我的 MySQL 数据库中的前 25 个项目。当我点击附加到我的 tableview 底部的“加载更多”单元格时,它成功获取了接下来的 25 个项目,但只加载前 40 个并离开最后 10 个。每次我点击“加载更多” "单元格将 25 添加到我的范围(即 0-25,25-50),但似乎我的范围上限为 65,显示上限为 40。

这是我的加载更多功能不起作用:

-(void) getNewRange{
    int currentRange = [allItems count];
    int newRange = currentRange + 25;

    if(newRange > [xmlParser total]){
        NSLog(@"evaluating as greater than the total, which is 837");
        newRange = [xmlParser total];
    }

    NSString *range = [[NSString alloc] initWithFormat:@"?range=%d&range2=%d",currentRange,newRange];
    NSString *newUrl =[[NSString alloc] initWithFormat:@"http://localhost/fetchAllTitles.php%@",range];

    XMLParser *tempParser = [[XMLParser alloc] loadXMLByURL:newUrl];
    [allItems addObjectsFromArray:[tempParser people]];
    NSMutableArray *newCells = [[NSMutableArray alloc] initWithCapacity:25];

    for(int i=currentRange;i<newRange;i++){
        NSLog(@"%d",i);
         NSIndexPath *indexpath=[NSIndexPath indexPathForRow:i inSection:0];
        [newCells addObject:indexpath];
    }

    NSLog(@"%@",newUrl);

    [self.tableView insertRowsAtIndexPaths:newCells withRowAnimation:UITableViewRowAnimationAutomatic];
}

我越来越近了,但我收到了这个新错误:

*** Assertion failure in -[_UITableViewUpdateSupport _computeRowUpdates], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableViewSupport.m:386

最佳答案

阅读如何重用表格 View 的单元格

您的数据不需要由单元“拥有”。

关于ios - 我无法在我的 UITableView 中加载超过 40 个 UITableViewCells,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12115945/

相关文章:

ios - Swift tableView 分页

ios - 关于 UIGestures 的困惑 - 消息接收者

ios - 如何从 NSURLSession 获取字符串形式的数据?

uitableview - [UITableViewCell _didChangeToFirstResponder :]: message sent to deallocated instance

swift - 如何在 UITableView 的编辑模式下将自定义单元格移动到左侧

php - 如何使用PHP在分页中添加事件类

javascript - 将 Backbone.Collection 用于分页列表?

ios - ARC下__weak UIViewController subview 创建简明代码

ios - 如何将 "Write a Review"/"Rate Us"功能添加到我的应用程序?

ios - 带部分的 UITableView 的最佳数据源配置