无法使用Firebase数据填充UICollectionView

时间:2017-03-04 19:20:49

标签: ios swift firebase uicollectionview firebaseui

我有一个Firebase数据库,我使用的是FirebaseUI iOS。该数据库包含我想用来填充UICollectionView的信息:

enter image description here

下面是我的ViewController代码,当前正在生成错误“无法分配FUICollectionViewDataSource类型的值”:

import UIKit
import FirebaseDatabase
import FirebaseDatabaseUI

private let reuseIdentifier = "PollCell"

class TrendingViewController: UICollectionViewController {

var ref: FIRDatabaseReference!
var dataSource: FUITableViewDataSource!


override func viewDidLoad() {
    super.viewDidLoad()

    ref = FIRDatabase.database().reference()

    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = false

    // Register cell classes

    self.dataSource = self.collectionView?.bind(to: self.ref) { collectionView, indexPath, snap in
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath)
        /* populate cell */
        return cell
    }

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
       }
  }

enter image description here

基本上,我希望使用Firebase中的数据填充客户单元格,它将是多个LabelsImageView。这是我创建的自定义单元格:

import UIKit

class PollCell: UICollectionViewCell {


@IBOutlet weak var imageView: UIImageView!

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier,
                                                  for: indexPath) as! PollCell

    return cell
   } 

}

enter image description here

任何帮助都将受到赞赏,因为我无法理解如何基本

0 个答案:

没有答案