当我打印出我在MyCell类中声明的IBOutlets时,它们显示为空。
ViewController中的方法。
在ViewController的viewDidLoad中,我应该用什么其他方式来初始化/注册MyCell类吗?
ViewController中的方法。
public override func viewDidLoad() {
super.viewDidLoad()
self.seriesCollectionView.register(MyCell.self, forCellWithReuseIdentifier: "MyCell")
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MyCell", for: indexPath) as! MyCell
cell.setup()
return cell
}
MyCell类
class MTSeriesViewCell: UICollectionViewCell {
@IBOutlet weak var cellView: UIView!
@IBOutlet weak var cellImageView: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
}
public func setup() {
print(cellView)
}
}
在ViewController的viewDidLoad中,我应该用什么其他方式来初始化/注册MyCell类吗?