-1

我有一个 UITableViewCell 并将其配置为启用编辑。一切正常,但我的问题是,当第二次按下圆形删除按钮(带有“|”的圆圈)时,删除确认不会消失。

有谁知道为什么会发生这种情况?

[编辑]

我将其缩小到每秒调用一次的方法,在该方法中我在可编辑的 UITableView 上调用 beginUpdates 和 endUpdates。有人知道解决方法吗?

4

3 回答 3

0

尝试添加如下内容:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    Dashboard *dashboard = [dashboards dashboardAtIndex:indexPath.row];
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        NSLog(@"delete");
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        NSLog(@"insert");
    }

    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
}

重新加载行是关键。

于 2012-08-13T13:39:05.950 回答
0

如果我不得不在黑暗中刺伤......您可能正在设置editing为 true,然后没有将其设置回 false。确保editing每次调用时设置值的任何方法都会反转其值。

- (void)setTableDelete 
{
    bool temp = !myTableView.editing;
    [myTableView setEditing:temp animated:YES];

}
于 2012-08-13T13:34:10.847 回答
0

如果 tableView 处于编辑模式,则通过避免使用 beginUpdates 和 endUpdates 方法来解决它,如果编辑模式为 YES,我会手动更新单元格。

于 2012-08-15T10:52:15.200 回答