MyCell 클래스에서 선언 한 IBOutlets를 인쇄하면 해당 값이 nil이됩니다.UICollectionView의 IBOutlets가 021입니다. 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") ** 셀 **에 대해 별도의 xib를 사용하지 않는 경우이 줄을 제거하십시오. – KKRocks