1

I have a UITableView with custom cells, and I want to make an edit mode similar to what is in iOS Mail app.

My view looks like this:

TableView

and when I tap Edit in top right corner, it changes to this:

TableView in edit mode

Those cats on the right are UIButtons. The problem is that when I tap them, Touch Up Inside or any other event is not fired.

Each cell has UITableViewCellEditingStyle set to none, so that I do not have the standard plus and minus icons. Instead, in my custom table cell view I put a UIButton (the cat) "outside the view" (X = -33) so that it appears when the TableView enters edit mode.

When I try to tap the cat, touch up inside is not fired, on the other hand, the expand button on the right works fine all the time.

Any ideas? Any help will be much appreciated.

BartoszCichecki
  • 2,227
  • 4
  • 28
  • 41

1 Answers1

1

Setting your "cat" button to -33 make it off the contentView of the cell. In this case the button is visible but it wont detect any touches or take any user interactions. Instead if doing this you can use the UITableView delegate methods:

-(void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath*)indexPath
{
 // add your "cat" button here
}

-(void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath*)indexPath
{
 // remove your "cat" button here
}
Pancho
  • 4,099
  • 1
  • 21
  • 32
  • It looks like those methods are not called when you set editing moge on uitableview. – BartoszCichecki Apr 29 '14 at 12:18
  • 1
    You can overwrite the UITableViewCell methods for editing modes -(void)setEditingAccessoryType;(UITableViewCellAccessoryType)editingAccessotyType or -(void)setEditingAccessoryView:(UIView*)editingAccessoryView – Pancho Apr 29 '14 at 12:25