NSInternalInconsistencyException:tableView中包含无效的更新?

时间:2013-12-30 10:27:09

标签: uitableview

这是我更新和动画tableview的方法 删除第1部分中的数据后,当我尝试更新该时间时,应用程序已崩溃 - (无效)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)

i just add bool variable and check if condition
if(!_reloading && !_isrecallbuiness )
{
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)];

}