使用自定义TableViewCell时,DeleteConfirmationButton不会消失

时间:2010-11-21 13:51:43

标签: ios iphone uitableview cocoa-touch button

当我使用滑动手势触发DeleteConfirmationButton时,我有一个自定义的TableViewCell(没有Interface Builder),然后触摸它,按钮就像往常一样消失。

但是当我使用默认编辑按钮将整个TableView设置为编辑模式时:

[self.navigationItem setRightBarButtonItem:[self editButtonItem]];

然后触摸DeleteConfirmationButton它只会变成深红色并且不会消失。

有什么想法吗?

PS:使用滑动手势时是否可以不显示按钮(因此只能在编辑模式下使用)?

编辑:了解我的意思(我只使用删除按钮清除星星)

http://dl.dropbox.com/u/940415/Screenshot%202010.11.21%2016.42.34.png

1 个答案:

答案 0 :(得分:1)

要删除删除按钮,您可以尝试:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // delete stars
        [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
}

PS的答案是肯定的。您可以使用以下内容:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (!tableView.editing) {
        return UITableViewCellEditingStyleNone;
    }
    return  UITableViewCellEditingStyleDelete;
}