NSInternalInconsistencyException:当我删除行然后更新表时,tableView中的更新无效

时间:2014-01-03 06:12:32

标签: uitableview

这是我在删除第1部分中的数据后更新和动画表视图的方法,当我尝试更新该时间时,应用程序已被破解 -

(void)onBusinessSuccess:(id)dataObj {

if([_ isBuisnessCall isEqualToString:IS_LABORDER]) {

BusinessSingleton *currentBusinessSingleton = [BusinessSingleton sharedInstance];
[[currentBusinessSingleton arrVirtualNetworkCall] removeObjectAtIndex:[currentBusinessSingleton containsObjectAtIndex:[self objLabOrderBusiness]]];

if(!_reloading){
    self.objLabTestVO = (LabTestVO*)dataObj;
    //adding the new rows
    __block NSMutableArray *insertArray = [[NSMutableArray alloc]initWithCapacity:10];
    [arrNewLabTestDataSource enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        [insertArray addObject:[NSIndexPath indexPathForRow:idx inSection:0]];
    }];

    __block NSMutableArray *insertArray1 = [[NSMutableArray alloc]initWithCapacity:10];
    [self.objLabTestVO.arrUnsignLab enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        [insertArray1 addObject:[NSIndexPath indexPathForRow:idx inSection:1]];
    }];

    __block NSMutableArray *insertArray2 = [[NSMutableArray alloc]initWithCapacity:10];
    [self.objLabTestVO.arrSignLab enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        [insertArray2 addObject:[NSIndexPath indexPathForRow:idx inSection:2]];
    }];

    [tableViewLeft beginUpdates];
    [tableViewLeft insertRowsAtIndexPaths:insertArray withRowAnimation:UITableViewRowAnimationTop];
    [tableViewLeft insertRowsAtIndexPaths:insertArray1 withRowAnimation:UITableViewRowAnimationTop];
    [tableViewLeft insertRowsAtIndexPaths:insertArray2 withRowAnimation:UITableViewRowAnimationTop];
    [tableViewLeft endUpdates];
    [tableViewLeft setContentInset:UIEdgeInsetsMake(1,0,0,0)];
    [tableViewLeft setContentInset:UIEdgeInsetsMake(0,0,0,0)];


}

1 个答案:

答案 0 :(得分:0)

我只是添加bool变量并检查条件

if(!_ reloading&&!_isrecallbuiness){

self.objLabTestVO =(LabTestVO *)dataObj;     //添加新行     __block NSMutableArray * insertArray = [[NSMutableArray alloc] initWithCapacity:10];     [arrNewLabTestDataSource enumerateObjectsUsingBlock:^(id obj,NSUInteger idx,BOOL * stop){         [insertArray addObject:[NSIndexPath indexPathForRow:idx inSection:0]];     }];

__block NSMutableArray *insertArray1 = [[NSMutableArray alloc]initWithCapacity:10];
[self.objLabTestVO.arrUnsignLab enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    [insertArray1 addObject:[NSIndexPath indexPathForRow:idx inSection:1]];
}];

__block NSMutableArray *insertArray2 = [[NSMutableArray alloc]initWithCapacity:10];
[self.objLabTestVO.arrSignLab enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    [insertArray2 addObject:[NSIndexPath indexPathForRow:idx inSection:2]];
}];

[tableViewLeft beginUpdates];
[tableViewLeft insertRowsAtIndexPaths:insertArray withRowAnimation:UITableViewRowAnimationTop];
[tableViewLeft insertRowsAtIndexPaths:insertArray1 withRowAnimation:UITableViewRowAnimationTop];
[tableViewLeft insertRowsAtIndexPaths:insertArray2 withRowAnimation:UITableViewRowAnimationTop];
[tableViewLeft endUpdates];
[tableViewLeft setContentInset:UIEdgeInsetsMake(1,0,0,0)];
[tableViewLeft setContentInset:UIEdgeInsetsMake(0,0,0,0)];

}