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.

4

1 回答 1

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];
    }
}
于 2012-11-04T10:27:05.467 回答