Rohan
Rohan

Reputation: 535

Cannot tap red minus delete button in UITableView

I am able to make the red minus button appear on each of my UITableViewCells with the following calls:

[self.tableview setEditing:YES];

and

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {

    return UITableViewCellEditingStyleDelete;
}

Now, the red minus buttons appear to the left of the UITableViewCells. However, I can't interact with them via a simple tap (only if I swipe from the red minus to the right).

I want the "Delete" button to appear when I tap on the "Red Minus" button, not just when I swipe.

Why isn't my "Red Minus" button listening to a tap gesture?

EDIT: Here's a screenshot of what my UITableViewCells look like:

Edit mode on my UITableViewCells

Upvotes: 3

Views: 1958

Answers (2)

Rohan
Rohan

Reputation: 535

Figured it out. I had a gesture recognizer getting in the way (dismisses the keyboard when you click outside of the searchbar).

once I removed that everything worked great!

Upvotes: 11

Tommy Devoy
Tommy Devoy

Reputation: 13549

Have you implemented the commitEditingStyle tableViewDelegate method?

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{  
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
}

Upvotes: 0

Related Questions