0
코드에서 사용하는 사용자 지정 UICollectionReusableView, HeaderCollectionReusableView가 있습니다. 그리고 차례로 UILabel이 포함됩니다. 라벨을 사용하려고 할 때 어떤 이유로 든 무효입니다. 우선 클래스를 등록한 다음 대기열에서 제거하려고합니다. 내가 뭘 놓치고 있니?UICollectionReusableView의 레이블은 항상 nil입니다.
override func viewDidLoad(){
super.viewDidLoad()
collectionView?.register(HeaderCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: colReusableViewIdentifier)
self.collectionView?.collectionViewLayout = UICollectionViewFlowLayout()
}
@objc override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let headerReusableView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: colReusableViewIdentifier, for: indexPath) as! HeaderCollectionReusableView
headerReusableView.headerLabel.text = "Reacshn"
return headerReusableView
}
를 사용하여. 제 경우에는 단순히 프로젝트를 정리하고 등록 호출없이 다시 빌드하는 것이 효과적이었습니다. –