为什么我不能将此单元格转换为从 swift 中的单元格继承的 class?

Why can I not cast this cell to a class that inherits from cell in swift?

我正在使用 UITableViewCOntroller 在 swift 中创建一个 TableView,这是我在其他几个应用程序中完成的,但是这次我尝试将我的单元格转换为自定义cell class 我收到无法投射的错误。

这是我的代码:

class CollapseNoteViewController: UITableViewController {

    let titleArray = ["Troy and Abed", "Shirly and Annie", "Pierce and Ben"]
    let noteArray = ["The best", "Pretty cool", "The worst"]
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return titleArray.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        // This is where I get the error
        let cell = tableView.dequeueReusableCell(withIdentifier: K.reuseIdentifier, for: indexPath) as! NoteTableViewCell 
        
        cell.titleLabel?.text = titleArray[indexPath.row]
        cell.textLabel?.text = noteArray[indexPath.row]
        
        return cell
    }
    
}

class NoteTableViewCell: UITableViewCell {

    @IBOutlet weak var cardView: UIView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var mainTextLabel: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }
    
}

完整的错误文本:

Could not cast value of type 'UITableViewCell' (0x1eccdbb70) to 'CollapseANote.NoteTableViewCell' (0x104d3ced8).
Could not cast value of type 'UITableViewCell' (0x1eccdbb70) to 'CollapseANote.NoteTableViewCell' (0x104d3ced8).
2021-02-18 10:36:47.613801-0500 CollapseANote[639:74162] Could not cast value of type 'UITableViewCell' (0x1eccdbb70) to 'CollapseANote.NoteTableViewCell' (0x104d3ced8).

我为原型单元设置 class 的地方:

我为 TableViewController 设置 class 的地方:

您嵌套到 table 个单元格并将 class 名称设置为内部单元格,这就是为什么 ist 在此处不可见的原因

喜欢把里面的拖出来

然后删除NoteItemCell

如果它代表另一个不同的单元格,则由您决定是否保留它