我得到错误 - 使用未声明的类型'BaseCell' - 尝试按照教程在Swift中创建Cell文件

问题描述 投票:0回答:1

我是一名新的程序员(自学成才)并且正在关注youtube教程(https://www.youtube.com/watch?v=PNmuTTd5zWc&t=21s),以学习如何为我的应用程序自下而上显示UICollectionView。

当我在4:50分钟尝试为BaseCell创建文件时,我没有收到错误。

使用未声明类型'BaseCell'

This is what it's supposed to look like according to the tutorial

我是否收到此错误,因为它不再存在于Swift中或可能存在什么错误?

有人可以帮帮我吗?

swift cell uicollectionviewcell collectionview
1个回答
0
投票

基本单元类是UIcollection视图单元类型的自定义类

class BaseCell: UICollectionViewCell
{
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpView()
    }

    func setUpView()
    {

    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init (coder:) has been implemented")
    }
}

如果你得到错误使用未声明的类型'BaseCell'然后再次构建你的项目它将工作。

© www.soinside.com 2019 - 2024. All rights reserved.