0

我正在构建一个使用 UICollectionView 的应用程序,但是当我注册我的 Cell 时,它给了我错误,

线程 1:EXC_BAD_ACCESS(代码=2,地址=0x7ffeeca55ff8)

我不知道这是什么意思,有人可以帮助我吗?对不起,如果我没有提供足够的代码,请询问我是否需要更多。这是我的代码:

import UIKit

class ThingsToDoCollectionView: UICollectionView {

override func register(_ cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String) {

    register(UICollectionView.self, forCellWithReuseIdentifier: "ThingsToDoCollectionViewCell")

    }


}

编辑:这是我的 ThingsToDoUICollectionViewCell 的代码

导入 UIKit

class ThingsToDoCollectionViewCell: UICollectionViewCell {


@IBOutlet weak var GIDThumbnail: UIImageView!
@IBOutlet weak var GIDTitle: UILabel!
@IBOutlet weak var GIDDueDate: UILabel!


}
4

1 回答 1

0

您应该在具有 UICollectionView 的 UIViewController 的 viewDidLoad 方法中注册单元格

self.collectionView.register(UINib(nibName: "YourCellXIBFileName", bundle: nil), forCellWithReuseIdentifier: "YourCellReuseIdentifier")
于 2019-06-08T21:20:37.673 回答