0

I want to display a "Duplicate" button where the Delete button would usually appear if the user swipes from left to right on a UITableView cell. I understand I can add a gesture recogniser to the cell as per this example https://stackoverflow.com/a/6167841/2567126.

How do I create and place a button on the cell so that it appears in a similar manner to the Delete button to allow the user to confirm the action? The cells are just standard UITableViewCells with the default style.

Community
  • 1
  • 1
Duncan Groenewald
  • 8,496
  • 6
  • 41
  • 76
  • You could add a UIButton as a subview of the cell – klcjr89 Jul 23 '13 at 01:44
  • You could try searching.. adding a UIButton as a subview is a trivial matter. – klcjr89 Jul 23 '13 at 01:51
  • That works great, any ideas on how to get the button to be placed on the left side, full height, width to match title and to shift the rest of the content of the cell to the right and include animation ? – Duncan Groenewald Jul 23 '13 at 02:04
  • I also need to detect when the user clicks elsewhere to remove the button so it works in a manner consistent with the Delete button? – Duncan Groenewald Jul 23 '13 at 02:11
  • Somehow I need to add a gesture recogniser when creating the Duplicate button to trap any gesture and then checking if the user clicked on the Duplicate button, if so then execute the duplicate function and remove the button, if not just remove the button. – Duncan Groenewald Jul 23 '13 at 02:31

1 Answers1

0

You can change the title of delete button with delegate method - tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:.

cahn
  • 1,350
  • 1
  • 12
  • 24
  • That's an option I guess, however I don't really want to change the left swipe/delete behaviour. I just want exactly the same behaviour for a right swipe but with a green Duplicate button appearing from the left side and the Edit button becoming a Done button. – Duncan Groenewald Jul 23 '13 at 03:24