我正在解析 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/