Here is the code that i have
import UIKit
class UserProfileController : UICollectionViewController, UICollectionViewDelegateFlowLayout{
override func viewDidLoad() {
super.viewDidLoad()
collectionView?.backgroundColor = .white
//NEED TO UPDATE: GET USERNAME TO AND SET NAVTITLE
fetchUser()
//UPDATE ALL USER PAGE INFO IN
collectionView?.register(UICollectionViewCell.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headerId")
}
fileprivate func fetchUser(){
//Assumed loged in get user ID
//guard let uid = currentUser?.uid else {return}
//NEED TO UPDATE: GET USERNAME FROM USER ID HASH
let username = "User Profile"
navigationItem.title = username
}
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerId", for: indexPath)
header.backgroundColor = .green
return header
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: view.frame.width, height: 200)
}
}
This all looks ok to me, I'm not sure what it is that is wrong here.
There doesn't seem to be anything wring with your code as posted. Perhaps an issue in your story board?