Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collection View Header not showing up

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.

like image 220
aadarshsg Avatar asked Jul 04 '13 07:07

aadarshsg


People also ask

How do you put a header in collection view?

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 .

What is swift UICollectionView?

An object that manages an ordered collection of data items and presents them using customizable layouts.


1 Answers

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.

like image 126
aadarshsg Avatar answered Sep 29 '22 09:09

aadarshsg