2012-11-04 2 views
0

이 가능한 중복 : 여기가져 오기 IndexPath있는 UITableViewCell의 하위 뷰에서


Detecting which UIButton was pressed in a UITableView 내 상황, 내 사용자 정의 UITableViewCell의 서브 뷰에 UITapGestureRecognizer를 추가, 나는에 인식기의 목표를 설정 내 tableviewcontroller, 그래서 내 tableviewcontroller 액션 메서드에서이 셀의 indexPath 얻을 수 알고 싶습니다.

+0

@flexaddicted 감사합니다. 정확하게 필요한 것입니다. – tassar

답변

0
- (IBAction)recognizerAction:(id)sender { 
    UITapGestureRecognizer *recognizer = sender; 

    if (recognizer.state == UIGestureRecognizerStateRecognized) { 
     YourCell *cell = (YourCell *)recognizer.view; 
     NSIndexPath *indexPath = [yourTableView indexPathForCell:cell]; 
     [self doSomethingWithIndexPath:indexPath]; 
    } 
} 
+0

'recognizer.view'는 내 셀의 서브 뷰라고 생각합니다. [뷰 슈퍼 뷰]에서'MyCustomCell'을 가져와야합니다. 어쨌든 고맙습니다. – tassar

관련 문제