0

Possible Duplicate:
Detecting which UIButton was pressed in a UITableView

here is my situation, I add a UITapGestureRecognizer to a subview of my custom UITableViewCell, I set recognizer's target to my tableviewcontroller, so I want to know how can I get this cell's indexPath from my tableviewcontroller's action method.

Community
  • 1
  • 1
tassar
  • 578
  • 3
  • 9

1 Answers1

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];
    }
}
Tomasz Wojtkowiak
  • 4,910
  • 1
  • 28
  • 35
  • i think `recognizer.view` is subview of my cell, i should get `MyCustomCell` from [view superview], thank you a lot anyway. – tassar Nov 04 '12 at 10:36