UITableView 分页加载数据时,每次请求回数据后都调用UITableView的reload方法显示新增加的数据。但是这样刷新了所有的cell,我尝试调用UITableView的insertRowsAtIndexPaths:withRowAnimation:方法,结果报NSInternalInconsistencyException错误,请问有其他解决方法只加载新增的数据吗?
共有 1 个回答 补充伪代码: int preCount = data.count; //把数据封装成一个数组添加到data中 //... [data addObject:newFetchedItem]; //... //构建NSIndexPath的数组 NSMutableArray *indexPaths = [[NSMutableArray alloc] init]; for(int i=preCount;i<data.count;i++){ //只有一个section [indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]]; } //调用UITableView的insertRowsAtIndexPaths:withRowAnimation: [tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
|