我试图设法从UITable
中删除一行,该行是UIViewController
的一部分。我使用导航栏中的Edit
按钮。点击它将把表格行置于编辑模式。但是,当连续的删除按钮被按下时使用以下时,我得到一个错误...'Invalid update: invalid number of rows in section 0….
:ios从ViewController中的表中删除行
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[self.tableView setEditing:editing animated:YES];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSMutableArray *work_array = [NSMutableArray arrayWithArray:self.inputValues];
[work_array removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
我怎么会错过吗?某种程度上,Apple文档似乎已过时。 谢谢
你好rmaddy,谢谢你的提示。我只是将附加数组取出并将其更改为我在数据模型中使用的数组。我太sl。了。谢谢! – JFS