Uitableview SwipCellKit swift 5-无法滑动以启动dele菜单

Uitableview SwipCellKit swift 5-无法滑动以启动dele菜单,uitableview,swift5,uiswipeactionsconfiguration,xcode11.2,Uitableview,Swift5,Uiswipeactionsconfiguration,Xcode11.2,我正在使用Xcode 11.2和Swift 5以及最新版本的SwipeCellKit 在我的代码中,我有一个带有单元格的UITableView。我希望从右侧添加滑动操作,这将允许我使用两个操作:删除和编辑 现在,我只尝试删除操作。然而,刷卡似乎不起作用,我没有得到任何行动 我错过了什么 这是我的密码: CartTableViewCell import UIKit import SwipeCellKit class CartTableViewCell: SwipeTableViewCell {

我正在使用Xcode 11.2和Swift 5以及最新版本的
SwipeCellKit

在我的代码中,我有一个带有单元格的
UITableView
。我希望从右侧添加滑动操作,这将允许我使用两个操作:删除和编辑

现在,我只尝试删除操作。然而,刷卡似乎不起作用,我没有得到任何行动

我错过了什么

这是我的密码:

CartTableViewCell

import UIKit
import SwipeCellKit

class CartTableViewCell: SwipeTableViewCell
{
    @IBOutlet weak var mainView: UIView!
    @IBOutlet weak var productName: UILabel!
    @IBOutlet weak var productImage: UIImageView!
    @IBOutlet weak var priceForKg: UILabel!
    @IBOutlet weak var quantity: UITextField!
    @IBOutlet weak var subTotal: UITextField!

    override func awakeFromNib()
    {
        super.awakeFromNib()

        self.layer.borderWidth = 1
        self.layer.cornerRadius = 25
        self.layer.borderColor = self.layer.backgroundColor

        self.mainView.layer.borderWidth = 1
        self.mainView.layer.cornerRadius = 25
        self.mainView.layer.borderColor = self.mainView.layer.backgroundColor

        self.quantity.layer.borderWidth = 1
        self.quantity.layer.borderColor = #colorLiteral(red: 0.8078431487, green: 0.02745098062, blue: 0.3333333433, alpha: 1)
        self.quantity.layer.cornerRadius = 5

        self.subTotal.layer.borderWidth = 1
        self.subTotal.layer.borderColor = #colorLiteral(red: 0.8078431487, green: 0.02745098062, blue: 0.3333333433, alpha: 1)
        self.subTotal.layer.cornerRadius = 5
    }
    override var frame: CGRect {
      get {
          return super.frame
      }
      set (newFrame) {
          var frame =  newFrame
          frame.origin.y += 4
          frame.size.height -= 2 * 5
          super.frame = frame
      }
    }
    override func setSelected(_ selected: Bool, animated: Bool)
    {
        super.setSelected(selected, animated: animated)
    }
}
CartViewController

import UIKit
import SwipeCellKit

class CartViewController: UIViewController
{
    @IBOutlet weak var cartTableView: UITableView!

    var listOfProducts : [Product] = []

    override func viewDidLoad()
    {
        super.viewDidLoad()

        self.cartTableView.delegate = self
        self.cartTableView.dataSource = self
        self.cartTableView.separatorStyle = .none
        self.cartTableView.allowsSelection = false
        self.cartTableView.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)


        self.subTotalView.layer.borderWidth = 1
        self.subTotalView.layer.borderColor = self.subTotalView.layer.backgroundColor
        self.subTotalView.layer.cornerRadius = 10

        let cellNib = UINib(nibName: "CartTableViewCell", bundle: nil)
        self.cartTableView.register(cellNib, forCellReuseIdentifier: "cartProductCell")
    }
}

extension CartViewController : UITableViewDelegate, UITableViewDataSource, SwipeTableViewCellDelegate
{
    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]
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {
        return listOfProducts.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
    {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cartProductCell", for: indexPath) as! CartTableViewCell
        return cell
    }
}

我找到了答案,如果你们中有人在寻找它,缺少的一行是在返回之前设置单元格的委托:

cell.delegate = self
如本文所述: