I am looking at various possible ways to implement delete-edit-copy feature on the UITableViewCell elements of a UITableView.
The one I am trying now is based on the usage of the following methods:
[tableView setEditing:YES animated:YES];
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath;
I can see some advantages to use this approach, but there is one problem:
When I try it, I can make the red “Delete” button appear and work, but that is all.
Is there a mechanism by which I could also have “edit” and “copy” buttons ?
Or is it just not possible?
Thanks for any helpful information.
EDIT
I just understood that you are referring to the cell, not the TableView. For the cell, the following styles are provided:
The cell has the delete editing control; this control is a red circle enclosing a minus sign.
The cell has the insert editing control; this control is a green circle enclosing a plus sign. You may use it for “copy”.
Further styles you have to implement on your own.
Original Answer
You can use the
editButtonItemmethod ofUIViewController. It returns a bar button item that toggles its title and associated state between “Edit” and “Done” (but not “Copy”). The default button action already invokes thesetEditing:animated:method.If you want another state, your have to create your own BarButtonItem.