2016-06-24 3 views
0

私はTableViewの代わりにCollectionViewを使用しています.CellViewCellをCustomCollectionViewCellを通して実装したいと思っていました。iOSのFirebaseUI populateCellWithBlockエラー

私はエラーを取得しています:

Could not cast value of type UICollectionViewCell to CustomCollectionViewCell

はまた、私はXIBを使用していません。カスタムコレクションビューセルにセルをキャストする正しい方法は何ですか?

dataSource = FirebaseCollectionViewDataSource.init(query: getQuery(), modelClass: Post.self, cellReuseIdentifier: "Cell", view: self.collectionView!) 

dataSource?.populateCellWithBlock() { 

    let cell = $0 as! CustomCollectionViewCell 

    let post = $1 as! Post 

    cell.textLabel.text = post.author    
} 

CustomCollectionViewCell.swift以下の通りである:

import UIKit 
import Firebase 

class CustomCollectionViewCell: UICollectionViewCell { 

    @IBOutlet weak var imageView: UIImageView! 
    @IBOutlet weak var textLabel: UILabel! 

} 
+0

は、あなたの 'CustomCollectionViewCell'コードを表示します。 – shim

+0

@shim CustomCollectionViewCell.swiftが質問に追加されました... –

+0

カスタムクラスを登録しましたか? (あなたの 'viewDidLoad'メソッドで' collectionView.registerClass(CustomCollectionViewCell.self、forCellWithReuseIdentifier: "Cell") ') – shim

答えて

0

はprototypeReuseIdentifierを使用してみてください:代わりにcellReuseIdentifierの "セル": "セル"

関連する問題