내 고객이 테이블 뷰 에디션 모드에서 제공 한 빨간색 원을 사용하지 않으므로 앱에 대한 맞춤 삭제 프로세스를 구현하려고합니다. 태그 속성에 행 번호가있는 모든 행에 삭제 버튼을 추가했습니다.프로그래밍 방식으로 UITableView에서 행을 삭제할 수 없습니다.
-(IBAction)deleteRow:(id)sender{
UIButton *tempButton = (UIButton*)sender;
[self updateTotals];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:tempButton.tag inSection:0];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView reloadData];
[sharedCompra removeItem:tempButton.tag];
tempButton=nil;
}
을 그리고 난에 allways이 오류 : 사용자가 삭제 버튼을 클릭하면, 그것은 다음과 같은 방법을 발사 나는이 코드 조각에 뭔가를 누락하는 경우
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).'
그래서 나도 몰라.
감사합니다. [tableView deleteRowsAtIndexPaths...
전에
많은 감사 !!!! – theomen