1
votes

I have a tableView that allows deletion by swiping a cell or entering edit mode via an "Edit" button. The problem is, I'm not sure how to properly enable/disable edit mode; it should be disabled as soon as a user begins to swipe a row, and enabled after "unswiping" a row.

Currently, I disable in editingStyleForRowAtIndexPath (which returns delete) and enable in didEndEditingRowAtIndexPath.

The problem is, what if the user doesn't finish their swipe? For example, they begin to swipe a row, but release before fully swiping (causing the row to bounce back and hide the delete button). In this case, didEndEditingRowAtIndexPath does not get called. How do I ensure the table is editable after a half-swipe?

1

1 Answers

-1
votes

Here you are another approach that work properly,(quit or comment: editingStyleForRowAtIndexPath and didEndEditingRowAtIndexPath.). And you must implement only this:

 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
    // Configure delete action:
    // First remove the delete data from you data source.
  Put here you code, like this:
  [self.theMutableArrayWithDataSourde removeObjectAtIndex:indexPath.row];
    // Second remove the cell:
  [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];


}
}