0

我发现当 tableview 被 UIPinchGestureRecognizer 声明为cellForRowAtIndexPath. 现在想要找到被捏住的特定单元格的 indexPath。所以我写了这样的......

- (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);
}

问题出在 indexPath.row 和单元格中,这两种情况的值都是空的。

所以,请有人帮我找到被夹住的 indexPath 或行。

4

1 回答 1

1

在行方法的单元格中,设置 cell.tag = indexpath.row 和

在 - (void)pinchDetected:(UIPinchGestureRecognizer*)gestureRecognizer 使用 UITableViewCell* cell = (UITableViewCell*)recognizer.view 再次从 cell.tag 你可以获得行索引。

于 2012-01-10T11:39:56.650 回答