我試圖通過滑動手指(如最近調用)來刪除tableView
上的單元格。我知道我需要實現:如何刪除手指在iPhone上滑動的單元格
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *index = [[NSArray alloc]initWithObjects:indexPath];
[self.tableView deleteRowsAtIndexPaths:index withRowAnimation: UITableViewRowAnimationNone];
}
但是,當我滑動手指,我得到這個功能和第二排,當我試圖刪除單元格的得到錯誤:
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 (4) must be equal to the number of rows contained in that section before the update (4), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).
有人可以幫忙嗎?