Ios 为整行的UITableViewCell平移手势,并在手势结束时执行操作
我需要像Swift中的editingStyle那样的平移手势,但我需要整个行的这个手势,以及手势结束时的DoAction,这会删除单元格 我不知道怎么做,因为我是初学者。我知道,我必须使用UIgestureRecognitor,但我不知道如何使用它。我找到了一些选项,但所有这些都只是用于删除,没有动画,我需要动画和背景来滑动 我只有以下显示动态数据的代码:Ios 为整行的UITableViewCell平移手势,并在手势结束时执行操作,ios,swift,uigesturerecognizer,Ios,Swift,Uigesturerecognizer,我需要像Swift中的editingStyle那样的平移手势,但我需要整个行的这个手势,以及手势结束时的DoAction,这会删除单元格 我不知道怎么做,因为我是初学者。我知道,我必须使用UIgestureRecognitor,但我不知道如何使用它。我找到了一些选项,但所有这些都只是用于删除,没有动画,我需要动画和背景来滑动 我只有以下显示动态数据的代码: override func tableView(_ tableView: UITableView, cellForRowAt indexPa
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TasksCell", for: indexPath) as! TasksCell
let arrayTasks = tasks[indexPath.row]
cell.taskName.text = arrayTasks.content
return cell
}
您能帮我吗?您可以使用UITableView委托方法删除行。无需使用平移手势。请试试这个
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
{
return true
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath)
{
if editingStyle == .delete
{
yourArray.remove(at: indexPath.row)
yourTableView.reloadData()
}
}
我正在使用它,但我想在整个单元格上不使用动画进行滑动的手势。