UICollectionView header not showing

前端 未结 3 1402
感动是毒
感动是毒 2021-01-31 14:21

I\'m working on a project that uses an UICollectionView to show several albums. The items show fine, but now I want to show an header above the first section.

3条回答
  •  别那么骄傲
    2021-01-31 14:58

    Did you implement:

    - (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
    

    There's a ton of methods to implement just to make one thing work...I'm learning too. Tell me if it works.

    Edit: Sorry wrong method. That is for subclassing I think. The one I'm talking about is in UICollectionViewLayout (the layout object you subclass, if your layout supports supplementary views):

    - layoutAttributesForSupplementaryViewOfKind:atIndexPath:
    

    See here: https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UICollectionViewLayout_class/Reference/Reference.html#//apple_ref/occ/cl/UICollectionViewLayout

提交回复
热议问题