3

I have a UICollectionView contains cell and header. I have 4 sections each section has 3 or 5 cell. My issue is the section header won’t stick until I get to the next section header as in the TableView. Please where would be my issue?

My code:

func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
    return 4
}

func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView
{

    let header = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: "headersection", forIndexPath: indexPath) as! MenuHeaderCollectionViewCell

    header.headerTitle.text = collectionheader[indexPath.row]

    return header
}

enter image description here enter image description here

CAN
  • 1,677
  • 4
  • 19
  • 28

1 Answers1

0

I guess you need to choose the proper FlowLayout. You will get what you need here.

Also check CSStickyHeaderFlowLayout

Community
  • 1
  • 1
Mayur Deshmukh
  • 1,169
  • 10
  • 25
  • So you are telling me there is no way like in the `TablevView` without framework? – CAN Aug 13 '15 at 08:26