0

我正在使用 CollectionView 而不是 TableView,我想通过 CustomCollectionViewCell 填充 CollectionViewCell,如果可以的话,我会徘徊。

我收到一个错误:

无法将类型的值UICollectionViewCell转换为 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!

}
4

1 回答 1

0

尝试使用prototypeReuseIdentifier:“Cell”而不是cellReuseIdentifier:“Cell”

于 2016-06-28T16:05:45.577 回答