Pinches时单元的IndexPath?

时间:2012-01-10 11:00:32

标签: iphone uitableview row pinch nsindexpath

我发现当使用UIPinchGestureRecognizer在cellForRowAtIndexPath处声明时,会查看tableview。现在想要找到被压缩的特定单元格的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和cell中,两个值得到的值都是null。

所以,plz可以帮助我找到被压缩的indexPath或行。

1 个答案:

答案 0 :(得分:1)

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

in - (void)pinchDetected:(UIPinchGestureRecognizer *)gestureRecognizer 再次使用来自cell.tag的UITableViewCell * cell =(UITableViewCell *)recognizer.view,你可以得到行索引。