ios从ViewController中的表中删除行

JFS

我尝试设法从中删除行,该行UITable是的一部分UIViewController我使用Edit导航栏中按钮。击中它将使表行进入编辑模式。但是,当按行中的删除按钮...'Invalid update: invalid number of rows in section 0….时,使用以下命令时出现错误

- (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];
    }
}

我在这里想念什么?苹果公司的文件似乎是某种方式已经过时。谢谢

rmaddy

问题很简单。从表中删除行之前,您没有正确更新数据模型。

您要做的就是创建一些新数组,并从中删除一行。那是没有意义的。您需要更新其他数据源方法(例如)使用的相同数组numberOfRowsInSection:

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章