本文介绍了断言失败 - [UITableView _endCellAnimationsWithContext]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我解析一个xml文件并将其解析的值放在表视图中。表视图只有一个部分。但我得到以下异常:
I am parsing an xml file and putting its parsed values in a table view.The table view has only one section.But i am getting following exception:
中的代码是:
/**
The NSOperation "ParseOperation" calls addFiles: via NSNotification, on the main thread which in turn calls this method, with batches of parsed objects. The batch size is set via the kSizeOfEarthquakeBatch constant.
*/
- (void)addFilesToList:(NSArray *)files {
NSInteger startingRow = [self.fileList count];
NSLog(@"STARTING ROW:%d",startingRow);
NSInteger fileCount = [files count];
NSLog(@"FILE COUNT : %d",fileCount);
NSMutableArray *indexPaths = [[NSMutableArray alloc] initWithCapacity:fileCount];
NSLog(@"INDEX PATHS:%@",indexPaths);
for (NSInteger row = startingRow; row < (startingRow + fileCount); row++) {
NSLog(@"into for");
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
NSLog(@"INDEXPAth %@",indexPath);
[indexPaths addObject:indexPath];
}
[self.fileList addObjectsFromArray:files];
NSLog(@"ADD objects");
NSLog(@"FILELIST:%@",self.fileList);
//GETTING EXCEPTION AT THIS LINE
[self.tableview insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic];
}
#pragma mark - UITableViewDelegate\
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
// The number of rows is equal to the number of earthquakes in the array.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.fileList count];
NSLog(@"NUMBER OF ROWS :%d",[self.fileList count]);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *kFileCellID = @"Cell";
myTableCell *cell = (myTableCell *)[tableView dequeueReusableCellWithIdentifier:kFileCellID];
// Get the specific earthquake for this row.
fileList *file = (self.fileList)[indexPath.row];
[cell configureWithFile:file];
return cell;
}
推荐答案
使用了两个indexPath(indexPath,lastIndexPath)。但对于lastIndexPath.row有我的数组bound.solve通过检查condition.hope这帮助某人。
In my case issue was i used two indexPath(indexPath,lastIndexPath). but for lastIndexPath.row had out of my array bound.solve by check condition.hope this help someone.
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, lastIndexPath, nil] withRowAnimation:UITableViewRowAnimationAutomatic];
这篇关于断言失败 - [UITableView _endCellAnimationsWithContext]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!