-(void)didSelectCellRowFirstDo:(BOOL)firstDoInsert nextDo:(BOOL)nextDoInsert
{
    self.isOpen=firstDoInsert;
    
    Cell1 *cell=(Cell1 *)[self.tableView cellForRowAtIndexPath:self.selectIndex];
    [cell changeArrayWithUp:firstDoInsert];
    
    [self.tableView beginUpdates];
    
    long section=self.selectIndex.section;
    long contentCount=[[[_dataList objectAtIndex:section]objectForKey:@"cat_list"]count];
    NSMutableArray * rowToInsert=[[NSMutableArray alloc]init];
    
    for (NSUInteger i=1; i<contentCount+1; i++) {
        NSIndexPath*indexPathToInsert=[NSIndexPath indexPathForRow:i inSection:section];
        [rowToInsert addObject:indexPathToInsert];
       
    }
    if (firstDoInsert) {
        
        [self.tableView insertRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];
    }
    else{
         [self.tableView deleteRowsAtIndexPaths:rowToInsert withRowAnimation:
         UITableViewRowAnimationTop];
        
    }
    
    [self.tableView endUpdates];
    if (nextDoInsert) {
        self.isOpen=YES;
        self.selectIndex=[self.tableView indexPathForSelectedRow];
        [self didSelectCellRowFirstDo:YES nextDo:NO];
    }
    if (self.isOpen) {
        [self.tableView scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionTop animated:YES];
    }
}

解决方案 »

  1.   

    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0.  The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (2 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'