Saturday, 18 February 2012

Get NSIndexPath on Custom Cell Button Tapped

Hello EveryBody,

For the UIButton of the Cell set the selector method as :

[theCell.button addTarget:self action:@selector(btnTapped:withEvent:) forControlEvents:UIControlEventTouchUpInside];

Now in selector method:

- (void)btnTapped:(id)sender withEvent:(UIEvent*)event {

          UITouch *touch = [[event touches] anyObject];
          CGPoint location = [touch locationInView:self.tableView];
          NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
}

This is how we do it.

Thanks

No comments:

Post a Comment