The view of the editing accessory is displayed when the cell enters editing mode. It seems like it is too complicated to actually get this work, but I managed it:
In order to display this both when entering editing mode for the entire table, and when scrolling through a single row, I performed the following in my subclass of UITableViewController:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated { if (editing) self.editingFromEditButton = YES; [super setEditing:(BOOL)editing animated:(BOOL)animated]; self.editingFromEditButton = NO;
editingFromEditButton is a BOOL property of a subclass. This method is called when the standard "Edit" button is clicked. It is used in the following method, which disables the standard delete button:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { if (self.editingFromEditButton) return UITableViewCellEditingStyleNone;
If the entire view of the table is set to edit mode, then each cell will also be sent a setEditing message. If we checked a single row, we need to make this cell go into edit mode, and then return the UITableViewCellEditingStyleNone style to prevent the standard delete button from appearing.
Then, to abandon the special editing accessory, you will also need the following code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Cancel the delete button if we are in swipe to edit mode UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if (cell.editing && !self.editing) { [cell setEditing:NO animated:YES]; return; } // Your standard code for when the row really is selected... }
jrturton
source share