UICollectionViewCell仅在第0部分填充

时间:2016-01-12 10:41:40

标签: ios uicollectionview

我在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
}

1 个答案:

答案 0 :(得分:0)

删除代码 -

cell.frame = cell.bounds