开发者

DeleteConfirmationButton does not disappear when using custom TableViewCell

I have a custom TableViewCell (without Interface Builder) when I use the swipe gesture to trigger the DeleteConfirmationButton to appear and then touch it the button disappears as usual.

But when I set the whole TableView in editing mode with the default edit button:

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

and then touch the DeleteConfirmationButton it only gets dark red and don't dissapears.

Any ideas?

PS: Is it possible to don't show the button when 开发者_运维技巧using the swipe gesture (so it only is available in editing mode)?

EDIT: To get an idea what I mean (I'm only using the delete button to clear the stars)

DeleteConfirmationButton does not disappear when using custom TableViewCell


To remove the delete button you can try:

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

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

The answer to your PS is yes. You can use something along the lines of:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜