简体   繁体   中英

IndexPath of a cell when Pinches?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM