chiahsien / CHTCollectionViewWaterfallLayout

The waterfall (i.e., Pinterest-like) layout for UICollectionView.
MIT License
4.53k stars 700 forks source link

Header not showing #156

Open MarcoMig opened 7 years ago

MarcoMig commented 7 years ago

Hello, I have follows all the precedures to show the header but is not working. Here what I've done:

If I run the project with this options the app will crash within the "viewForSupplementaryElementOfKind" method.

To fix this error I had to register my header view in my viewDidLoad:

    self.collectionView?.registerClass(UICollectionReusableView.self, forSupplementaryViewOfKind: CHTCollectionElementKindSectionHeader,withReuseIdentifier: "collectionHeader")

Now the app don't crash but as a result now I see a blank header.

enhancient commented 7 years ago

Hi @MarcoMig,

I'm not sure if this helps, but I had success using a nib approach:

let nib = UINib(nibName: "HeaderCollectionReusableView", bundle: nil) self.collectionView?.register(nib, forSupplementaryViewOfKind: CHTCollectionElementKindSectionHeader, withReuseIdentifier: "collectionHeader")

pippo27 commented 7 years ago

Don't forget to conform to protocol CHTCollectionViewDelegateWaterfallLayout.

func collectionView (collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,
        heightForHeaderInSection section: NSInteger) -> CGFloat
satashiabhavin commented 5 years ago

deinit { SDWebImageDownloader.shared.cancelAllDownloads() }

girish54321 commented 2 years ago

Thanks @pippo27