2013-05-25 2 views
0

편집 모드에서 선택할 수있는 tableView에서 [tableView setEditing : NO animated : YES]를 호출하고 편집 모드를 종료 할 때 어떤 셀이 선택된 셀인지 어떻게 알 수 있습니까?[tableView setEditing : NO]를 호출 할 때 선택된 셀 indexPath를 찾는 방법은 무엇입니까?

didDeselectRowAtIndexPath에 대한 호출이 없습니다. 내가 간과 한 다른 방법이 있습니까? 솔루션

편집 :

셀을 선택 해제 결코 극복

이 때문에 indexPathForSelectedRow 여전히 올바른 값을 반환합니다. 공정하다.

답변

0

이 경우 GestureRecognizer를 사용할 수 있습니다.

이 시도 :

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]; 
} 
+0

안녕 사미르, 정확히 무슨 뜻인지 확실하지 않습니다. 내 질문을 편집했을지 모르겠다. – ceekay

0

대답은 행이 선택 해제 결코 극복한다는 것입니다.

indexPathForSelectedRow는 실제로 편집 모드를 종료하기 전에 유효합니다.