여기에 내가프로그래밍 방식
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)
}
}
이 모두가 나에게 좋아 보이는이 그 코드입니다, 메신저 확실하지가 그 여기에 잘못이 무엇인지. 고급
당신은'UICollectionViewDataSource'의'numberOfSections' 함수를 재정의나요? 이 프로토콜을 전혀 구현하지 않았습니까? 컬렉션에 데이터를 표시하지 않는 한 아무 것도 볼 수 없으므로 –
이 함수를 무시하고 아무 것도 발생하지 않습니다. – NojDavid