Search code examples
iosswiftheaderfootercollectionview

How to show Header without show Cell in CollectionView iOS Swift 4?


I have collection view with Cell,Header and Footer. some of indexes in my datasource not have object that contains cell data, Therefore I want to not show cell for that indexes.
I tried to set return nil in cellForItemAt but it's not possible.
Help me to fix this.


Solution

  • Return 0 in collectionView(_:numberOfItemsInSection:).