捏合时单元格的 IndexPath?
我发现当 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 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.