I am trying to add a header to UICollectionView
. I used storyboard and checked Section Header. A new cell appeared and I am trying to add content to it (A label with some text). The issue is I can see the label in the storyboard but it does not appear in runtime.
In order to make sure that header is showing up, I changed the background color to yellow and I was able to see yellow header in runtime. Still no label.
Help is much appreciated.
There are no section headers in the UICollectionView. So for your first task, you'll add a new section header using the search text as the section title. To display this section header, you'll use UICollectionReusableView .
An object that manages an ordered collection of data items and presents them using customizable layouts.
Found the fix. I was calling registerClass:forSupplementaryViewOfKind:withReuseIdentifier:
in viewDidLoad
.
When using storyboards, registration is done internally and the above call was messing things up. Deleting the line of code fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With