testing testing - 1 month ago 19
iOS Question

Disable supplementary view

What is the correct of of disabling the supplementary views (e.g. header)? One time I want to show them (iPhone) and one time I don't want to show them (iPad).

The only idea I currently have is to return a size of zero in

referenceSizeForHeaderInSection
. But I think it's kind of an overhead to create views, which aren't used at all. On the other side I have to implement
collectionView:viewForSupplementaryElementOfKind:atIndexPath:
and I can't return
nil
, because the app crashes then.

How can I disable the supplementary views in
UICollectionView
?

feb feb
Answer

If you return CGSizeZero from collectionView:layout:referenceSizeForHeaderInSection: delegate method collectionView:viewForSupplementaryElementOfKind:atIndexPath: won't be called.