IndexPath of a cell when Pinches?

230 Views Asked by At

I am finding when tableview is pinched with UIPinchGestureRecognizer declaring at cellForRowAtIndexPath. Now want to find indexPath of a particular cell that was pinched. so i wrote the like this...

- (void)pinchDetected:(UIPinchGestureRecognizer*)gestureRecognizer {
    CGPoint p = [gestureRecognizer locationInView:tblAccountsList];
    NSIndexPath *indexPath = [tblAccountsList indexPathForRowAtPoint:p];
    NSLog(@"indexPath.row = %@", indexPath.row);
    UITableViewCell *pinchedCell  = [tblAccountsList cellForRowAtIndexPath:indexPath];
    NSLog(@"pinchedCell = %@", pinchedCell);
}

Problem is in indexPath.row and cell both cases value am getting is null.

So, plz can someone help me to find the indexPath or row that was pinched.

1

There are 1 best solutions below

8
On

in cell for row method, set cell.tag = indexpath.row and

in - (void)pinchDetected:(UIPinchGestureRecognizer*)gestureRecognizer use UITableViewCell* cell = (UITableViewCell*)recognizer.view again from cell.tag you can get the row index.