Ios 从UILongPress识别器确定序列的单元格

Ios 从UILongPress识别器确定序列的单元格,ios,iphone,swift,uitableview,Ios,Iphone,Swift,Uitableview,我正在构建一个基本的清单应用程序,但有一个小问题 在定期点击表格视图单元格时,我使用preparefor segue切换到我的NewTaskViewController: 我还对添加到手机中的UILongPressGestureRecognitor执行了一个序列。长按应该会切换到同一个NewTaskViewController,但这次会将单元格的TaskItem添加到其taskToEdit属性中 当我使用UILongPress识别器时,我正在努力找出如何确定长按单元格的索引路径,以便传递正确的项

我正在构建一个基本的清单应用程序,但有一个小问题

在定期点击表格视图单元格时,我使用preparefor segue切换到我的NewTaskViewController:

我还对添加到手机中的UILongPressGestureRecognitor执行了一个序列。长按应该会切换到同一个NewTaskViewController,但这次会将单元格的TaskItem添加到其taskToEdit属性中

当我使用UILongPress识别器时,我正在努力找出如何确定长按单元格的索引路径,以便传递正确的项目

从本质上讲,如何从手势识别器中识别表视图单元格


提前谢谢

那么,您可以在处理函数中尝试类似的操作吗

if longPressGestureRecognizer.state == UIGestureRecognizerState.Began {
    let touchPoint = longPressGestureRecognizer.locationInView(self.view)
    if let indexPath = tableView.indexPathForRowAtPoint(touchPoint) {
        // Your Stuff
    }
}

非常感谢!我在这里做的是将indexPath存储在类中的存储属性中,并在prepareForSegue中访问它!
    } else if segue.identifier == "EditTask" {
        let nav = segue.destination as! UINavigationController
        let editTaskVc = nav.topViewController as! NewTaskViewController
        editTaskVc.delegate = self
        editTaskVc.managedContext = managedContext
        editTaskVc.taskToEdit = ?
if longPressGestureRecognizer.state == UIGestureRecognizerState.Began {
    let touchPoint = longPressGestureRecognizer.locationInView(self.view)
    if let indexPath = tableView.indexPathForRowAtPoint(touchPoint) {
        // Your Stuff
    }
}