捏合时单元格的 IndexPath?

发布于 2024-12-26 02:12:25 字数 619 浏览 3 评论 0原文

我发现当 tableview 被 cellForRowAtIndexPath 声明的 UIPinchGestureRecognizer 挤压时。现在想要找到被挤压的特定单元格的索引路径。所以我写了这样的...

- (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和单元格中,两种情况下得到的值都是空的。

所以,请有人帮我找到被挤压的索引路径或行。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红玫瑰 2025-01-02 02:12:26

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文