MyCellクラスで宣言したIBOutletsを印刷すると、それらはゼロになります。UICollectionViewのIBOutletsがnil - Swift
方法の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クラスを初期化する必要がある他の方法はありますか?
あなたはインターフェイスビルダーでセルUIを作るのですか?もしそうならセル – SeanLintern88
self.seriesCollectionView.register(MyCell.self、forCellWithReuseIdentifier: "MyCell") **セルを登録する場所を表示してください。 – KKRocks