Ios TableView:locationInView为具有UITableViewAutomaticDimension高度的单元格返回错误值

Ios TableView:locationInView为具有UITableViewAutomaticDimension高度的单元格返回错误值,ios,swift,uitableview,uigesturerecognizer,Ios,Swift,Uitableview,Uigesturerecognizer,我有一个具有动态行高的表视图: func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return UITableViewAutomaticDimension } func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSInde

我有一个具有动态行高的表视图:

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
  return UITableViewAutomaticDimension
}

func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return 80.0
}
此表格视图有一个相关的手势识别器,用于处理长按其单元格的操作,当发生这种情况时,我会在视图中获得触摸的位置,如下所示:

let locationInView = recognizer.locationInView(tableView)
let indexPath = tableView.indexPathForRowAtPoint(locationInView)
问题在于,当第一次显示单元格时,locationInView返回错误的值,下一次返回正确的值。发生这种情况是因为细胞的自动尺寸,但我还没能修复它。有什么线索吗


提前感谢

如果手势识别器在每个单独的单元格上,效果会更好吗?我也尝试过,但得到了相同的结果:s。谢谢嗯,我注意到了整个自动可变高度系统的一些特点,我不喜欢,所以也许最好的解决方案是不使用它。毕竟,多年来我们在没有它的情况下做得很好。您必须实现
heightForRow
,并事先为所有单元格进行测量,但这并不难。