swift - 使用覆盖将 SwipeCellKit 连接到自定义单元格 - Swift
问题描述
当我加载填充自定义(xib)单元格的 UITableViewController 时,我的应用程序崩溃并出现错误:
无法将类型“SwipeCellKit.SwipeTableViewCell”的值转换为“GreenHarvestAlpha.ListCell”。
然而,ListCell
有祖父母班SwipeTableViewCell
。
如果我不向下转换,类ListViewController
将不会连接到自定义单元(并且我会收到我的自定义单元的属性不存在的构建时错误)。
自定义单元格
class ListCell: SwipeTableViewCell {
滑动类 (出列单元格)
`class SwipeVC: UITableViewController, SwipeTableViewCellDelegate {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: K.cellSwipeIdentifier, for: indexPath) as! SwipeTableViewCell
cell.delegate = self
return cell }
func updateModel(at indexPath: IndexPath) {
//leave empty. override in CategoryVC & ListVC with delete from realm functionality
}
列表类(崩溃并出现向下错误):
class ListViewController: SwipeVC
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = super.tableView(tableView, cellForRowAt: indexPath) as! ListCell
另外,我已经在另一个类中覆盖了原型单元,这个过程正在为此工作。
解决方案
推荐阅读
- powershell - 通过脚本设置 IIS 环境变量
- cypress - 无法在 Cypress 上选择 chrome 浏览器
- sass - 使用 @use 设置 SASS 模块“库”以允许用户覆盖库变量的正确方法是什么?
- c - 如何使用适用于 2 个微控制器的嵌入式 C 为嵌入式系统编写可移植代码?
- django - 将 Django F 表达式与 Case、When 表达式一起使用
- sql - Postgresql 在位置 3 中从右侧替换逗号并将点和逗号从左侧替换到该位置
- redirect - 谁应该设置重定向?
- java - 如何在Android中使用接口作为监听器和Dialoge?
- gstreamer - 'num-buffers' 在 gstreamer 中有什么作用?
- python - 我想从名为scores的txt文件中显示数字的对应字母