我在UICollectionView
上创建了storyboard
创建了一个自定义单元格,部分数量为5,但单元格仅出现在最顶部。
我的代码是 -
override func viewDidLoad() {
self.collectionView!.registerClass(UICollectionReusableView.self, forSupplementaryViewOfKind:UICollectionElementKindSectionHeader, withReuseIdentifier: "MyHeaderView");
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 5
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("PSCell", forIndexPath: indexPath) as! PSCollectionViewCell
cell.frame = cell.bounds
return cell
}
答案 0 :(得分:0)
删除代码 -
cell.frame = cell.bounds