Swift 如何在SwipeCellKit中实现左右滑动

Swift 如何在SwipeCellKit中实现左右滑动,swift,xcode,Swift,Xcode,我正在按照教程创建一个简单的待办应用程序,我希望用户能够使用SwipeCellKit向左滑动以编辑单元格,向右滑动以删除单元格。我已经创建了一个SwipTableViewController来运行代码,这样我就可以在其他ViewController中调用它,并使用了github repo上的代码文档。这是我添加的代码: func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for or

我正在按照教程创建一个简单的待办应用程序,我希望用户能够使用SwipeCellKit向左滑动以编辑单元格,向右滑动以删除单元格。我已经创建了一个SwipTableViewController来运行代码,这样我就可以在其他ViewController中调用它,并使用了github repo上的代码文档。这是我添加的代码:

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? {
guard orientation == .right else { return nil }

let deleteAction = SwipeAction(style: .destructive, title: "Delete") { action, indexPath in
    // handle action by updating model with deletion
}

// customize the action appearance
deleteAction.image = UIImage(named: "delete")

return [deleteAction]
}
我在哪里实现左方向?
(请友善一点,我只是个新手,所以如果这是一个愚蠢的问题,我道歉)

这条线阻止你执行左方向,因为守卫声明只检查右方向

guard orientation == .right else { return nil }
如果要处理这两种情况,应将guard语句更改为If语句,如下所示:

if orientation == .right{
   //Do Something with right swipe
}
else{
  //Do Something with left swipe
}

这一行阻止您实现左方向,因为guard语句只检查右方向

guard orientation == .right else { return nil }
如果要处理这两种情况,应将guard语句更改为If语句,如下所示:

if orientation == .right{
   //Do Something with right swipe
}
else{
  //Do Something with left swipe
}