0
테이블 뷰에서 셀을 삭제할 때 충돌이 발생합니다. 나는 NSUserDefaults
에서로드 된 NSMutableArray
을 사용하여 셀을 tableview에로드합니다. 코드 :행을 삭제할 때 테이블 뷰 충돌이 발생합니까?
2011-09-03 18:21:06.097 App[10356:707] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-1906/UITableView.m:1046
2011-09-03 18:21:06.100 App[10356:707] *** 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 (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
이 내가 행을 삭제하는 방법입니다 ... 코드 :
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
[self.cellArray objectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath] withRowAnimation:YES];
[[NSUserDefaults standardUserDefaults] setObject:cellArray forKey:@"cellArray"];
}
이 내 numberOfRowsInSection
위임 방법 : 코드 : // 사용자 정의 이 충돌입니다 테이블 뷰의 행수
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
self.cellArray = [NSMutableArray array];
[self.cellArray addObjectsFromArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"cellArray"]];
if ([self.cellArray count] == 0) {
[ivstatstableView setHidden:YES];
[sortbar setEnabled:NO];
}
return [cellArray count];
}
무엇이 잘못 되었습니까?