0

여기에 내가프로그래밍 방식

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) 
    } 
} 

이 모두가 나에게 좋아 보이는이 그 코드입니다, 메신저 확실하지가 그 여기에 잘못이 무엇인지. 고급

+0

당신은'UICollectionViewDataSource'의'numberOfSections' 함수를 재정의나요? 이 프로토콜을 전혀 구현하지 않았습니까? 컬렉션에 데이터를 표시하지 않는 한 아무 것도 볼 수 없으므로 –

+0

이 함수를 무시하고 아무 것도 발생하지 않습니다. – NojDavid

답변

0

에서

덕분에 게시 된 아무것도 코드로 짜있을 것 같지 않습니다. 스토리 보드에 문제가 있습니까?

enter image description here

+0

경고를받습니다. main.storyboard를 사용했지만 프로그래밍 방식으로 모든 작업을 수행 했으므로 스토리 보드가 비어 있고 매번 실행됩니다. 인스턴스를 생성하지 못했습니다. UIMainStoryboardFile 'Main'의 기본보기 컨트롤러 - 지정된 엔트리 포인트가 설정되지 않았습니까? – NojDavid

+0

컬렉션보기를 볼 수 있습니다. 배경을 빨간색으로 설정하면 화면이 빨간색으로 표시되어 헤더가 표시되지 않습니다. – NojDavid

+0

어떻게 표시 했습니까? 나는 이것을 시험해보고 아직도 couldnt 할 나의 프로젝트를 다시 만들어 냈다. DId 언제 만들었 니? – NojDavid