初学者です。
何が原因でエラーになったか検討もつかないので、ページ全て貼り付けています。
追加のご指摘あれば、お答えします。
よろしくお願いします。
import UIKit import Firebase private let reuseIdentifier = "Cell" private let headerIdentifier = "UserProfileHeader" class UserProfileVC: UICollectionViewController, UICollectionViewDelegateFlowLayout { // MARK: - Properties override func viewDidLoad() { super.viewDidLoad() // register cell classes ##############エラー############## Use of unresolved identifier 'UserPostCell' self.collectionView!.register(UserPostCell.self, forCellWithReuseIdentifier: reuseIdentifier) self.collectionView!.register(UserProfileHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerIdentifier) // background color self.collectionView?.backgroundColor = .white // fetch user data fetchCurrentUserData() } // MARK: - UICollectionView override func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 } override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { // #warning Incomplete implementation, return the number of items return 0 } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { return CGSize(width: view.frame.width, height: 200) } override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { // declare header let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerIdentifier, for: indexPath) as! UserProfileHeader // return header return header } override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) // Configure the cell return cell } // MARK: - API func fetchCurrentUserData(){ guard let currentUid = Auth.auth().currentUser?.uid else { return } Database.database().reference().child("users").child(currentUid).child("username").observeSingleEvent(of: .value) { (snapshot) in guard let username = snapshot.value as? String else { return } self.navigationItem.title = username } } }
UserPostCellを定義
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! UserPostCell // Configure the cell return cell }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/28 11:22