我是Objective-C的新手。因此,我在表格(5个单元格)中有5行的表格视图,我想让用户删除它们,但是当我点击删除按钮时,应用程序不断崩溃。它崩溃的原因是因为我有5行的部分,而不是返回[self.myListItems计数]如何纠正下面的代码,同时保持5行的部分?如何删除tableView单元格iOS
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[self.myListItems removeObjectAtIndex:indexPath.row];
[self saveList];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
的错误是:在断言失败 - [UITableView的_endCellAnimationsWithContext:]
你重装的TableView一个单元已被删除后?顺便说一句,为什么你要保留5行,即使你删除一个单元格,这应该减少行数? – DCDC
你的意思是你在'numberOfRowsInSection'中返回静态5吗? –
http://stackoverflow.com/questions/10134841/assertion-failure-in-uitableview-endcellanimationswithcontext –