Staeff
Staeff

Reputation: 5084

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)

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

Upvotes: 1

Views: 501

Answers (1)

Robert Höglund
Robert Höglund

Reputation: 10080

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

Upvotes: 1

Related Questions