編程註冊我的頭好像沒有顯示出來,甚至我已經註冊程序中UICollectionViewFlowLayout。只是空白。頭沒有出現在UICollectionView起來,甚至已經在UICollectionViewFlowLayout
我的代碼
override func viewDidLoad() {
super.viewDidLoad()
UICollectionReusableViewlet layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
layout.itemSize = CGSize(width: 117, height: 117)
layout.minimumLineSpacing = 1
collectionView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
collectionView!.dataSource = self
collectionView!.delegate = self
collectionView!.registerClass(EventHeaderView.self, forSupplementaryViewOfKind:UICollectionElementKindSectionHeader, withReuseIdentifier: "MyHeaderView");
collectionView!.registerClass(EventDetailCollectionViewCell.self, forCellWithReuseIdentifier:"MyCollectionViewCell")
collectionView!.backgroundColor = UIColor.blackColor()
self.view.addSubview(collectionView!)
}
func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
switch kind {
//2
case UICollectionElementKindSectionHeader:
//3
let headerView =
collectionView.dequeueReusableSupplementaryViewOfKind(kind,
withReuseIdentifier: "HeaderView",
forIndexPath: indexPath)
as! EventHeaderView
headerView.lblName.text = "Anniversary"
headerView.lblDescription.text = "Venue"
return headerView
default:
//4
assert(false, "Unexpected element kind")
}
}
請指點。謝謝。
我已經做BRO包括設置頭標識符。 –
確保您已設置高度爲情節提要/自定義UICollectionViewDelegateFlowLayout頭。它發生在我身上一次。我已經爲頭文件1定義了高度。 –
已經通過檢查員設置了它。還是一樣。 –