3
votes

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

2
How do you create and add subviews to your cells? And are you using UITableViewController? - Wain
They're actually all dropped in through the storyboard. I just called HIDE on certain subviews when I enter editing mode (e.g. there's an icon that appears where the "Red Minus" button is in the SS above, I hide that and then show the "Red Minus" button by calling setEditing). And no, I'm using a ViewController like so: @interface AHBBrowseContactsViewController : AHBViewController <UITableViewDataSource, UITableViewDelegate, MFMessageComposeViewControllerDelegate,AHBSelectorPickleDelegate> - Rohan
You use 'hidden' to hide or 'alpha'? - Wain
Hidden. For example: self.shareButton.hidden = YES; self.callButton.hidden = YES; self.customPublicSwitch.hidden = NO; - Rohan
Also, just realized that my table is editable even when I comment out the "setEditing" line...is that normal? - Rohan

2 Answers

11
votes

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!

0
votes

Have you implemented the commitEditingStyle tableViewDelegate method?

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