0

On a tableView that allows selection in edit mode, how do i find which was the selected cell when i call [tableView setEditing:NO animated:YES] and exit edit mode ?

There is no call to didDeselectRowAtIndexPath:, are there any other methods i overlooked ?

Edit for solution:

The cell never gets deselected, therefore indexPathForSelectedRow still returns the correct value. Fair enough.

ceekay
  • 1,167
  • 1
  • 10
  • 14

2 Answers2

0

you can use GestureRecognizer for this .

try this :

   UISwipeGestureRecognizer *gestureObj = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(Method:)];
  [gestureObj setDirection:UISwipeGestureRecognizerDirectionRight];
  [self.tableview addGestureRecognizer:gestureObj];


-(void)Method:(UISwipeGestureRecognizer *)gestureRecognizer {
    CGPoint p = [gestureRecognizer locationInView:self.tableview];

    NSIndexPath *indexPath = [self.tableview indexPathForRowAtPoint:p];
    if (indexPath == nil)
    {
        [self setEditing:YES animated:YES];
        NSLog(@"slide on table view but not on a row");
    }

    else
    {
        [self setEditing:YES animated:YES];
        NSLog(@"slide on table view at row %d", indexPath.row);
    }
    UITableViewCell *cell = [self.MYArray objectAtIndex:indexPath.row];
}
SAMIR RATHOD
  • 3,512
  • 1
  • 20
  • 45
0

The answer is that the row never gets deselected.

indexPathForSelectedRow is still valid before actually exiting the edit mode.

ceekay
  • 1,167
  • 1
  • 10
  • 14