I was able to solve this problem, but, unfortunately, it requires additional work and is not as simple as setting a couple of properties.
In my
- (UITableViewCellEditingStyle)tableView:(UITableView *)_tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
I am returning a UITableViewCellEditingStyleNone so that a custom editingAccessoryView . In this method, I also do this:
self.tableView.scrollEnabled = NO; if(self.editingPath) { [[tableView cellForRowAtIndexPath:editingPath] setEditing:NO animated:YES]; } self.editingPath = indexPath; for (UITableViewCell *cell in [tableView visibleCells]) { cell.selectionStyle = UITableViewCellSelectionStyleNone; }
This disables scrolling and then saves the indexPath , which we used for later use. If you draw another line by editing the line, it will turn off the first line and edit the second line, as apple applications do. I also set the selectionStyle cell for all visible UITableViewCellSelectionStyleNone cells. This reduces blue flickering when the user selects another cell during editing.
Next, we need to reject the accessoryView when another cell is involved. To do this, we implement this method:
-(NSIndexPath *)tableView:(UITableView *)_tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { if(self.editingPath) { UITableViewCell *c = [tableView cellForRowAtIndexPath:self.editingPath]; [c setEditing:NO animated:YES]; self.tableView.scrollEnabled = YES; self.editingPath = nil; for (UITableViewCell *cell in [tableView visibleCells]) { cell.selectionStyle = UITableViewCellSelectionStyleBlue; } return nil; } return indexPath; }
What does this mean when someone is going to click on a cell, if we are editing, then unedit this cell and do not return anything.
also for
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
I am returning YES to allow editing on the cells that I want the user to be able to delete.
source share