ios - 使用自定义 UITableViewCell 时,删除确认按钮不会消失

标签 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

最佳答案

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

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

关于ios - 使用自定义 UITableViewCell 时,删除确认按钮不会消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4238177/

相关文章:

iphone - 关于弱引用和保留循环的说明

iphone - TableView addGesture 到 UIImageView 以了解哪个单元格被点击

ios - 静态函数返回 UIView 遇到 SIGBART 错误(SWIFT)

ios - 没有在 UIView 中调用自定义 setter

ios - __block 没有 block 的存储类型?

iphone - keyboardWillShowNotification 边缘案例

ios - 当我按下按钮时,我想要添加文本字段的内容 - IOS TableView

ios - 为什么弹出 UIViewController 会改变 navigationItem 的 titleTextAttributes?

iphone - iPhone 上 Lua 的文件与数据库

iphone - 用于手指触摸绘图的 UIBezierPath 平滑曲线