如何将 SwipeCellKit 的自定义滑动功能用于从 .xib 文件创建的自定义单元格?

How can I use the custom swipe capabilities of SwipeCellKit for a custom cell created from a .xib file?

我有一个使用 CustomCell.xib 以及与之配套的 class 制作的自定义单元格。我使用它的方式是在 viewDidLoad():

中注册我的自定义单元格
categoryTableView.register(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "customCell")
configureTableView()

然后我这样设置单元格: 让 cell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath) 作为!自定义类别单元格

现在,我想使用一个名为 SwipeCellKit 的 CocoaPod,它使单元格能够进行滑动操作以及添加图像并使滑动完全可定制。

为了用这个!我必须将单元格的向下转换更改为 as! SwipeTableViewCell.

所以我的问题是:有没有一种方法可以同时使用我的自定义单元格和 SwipeCellKit CocoaPod?

我最初的想法是转到 table 视图控制器并直接在那里创建自定义单元格而不是在自定义 .xib 文件中,或者复制并粘贴 GitHub 中给出的代码] 项目。

有什么想法吗?

非常感谢您!

您应该将 SwipeTableViewCell 作为自定义单元格的 超类,而不是 UITableViewCell

import UIKit
import SwipeCellKit

class CustomCell: SwipeTableViewCell {
    [...]
}