Swift   发布时间:2022-04-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了新的FUITableViewDataSource – 如何使用?斯威夫特3大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
刚刚更新到更新的firebaseui Pod – 一些事情已经改变,但其中一个重要的是FUI表视图的工作方式.我在旧版本上运行良好,但我正在努力解决这个问题 – 而且缺乏文档/示例.

self.datasource = FUITableViewDatasource(query: <#T##FIRDatabaseQuery#>,view: <#T##UITableView#>,populateCell: <#T##(UITableView,IndexPath,FIRDataSnapshot) -> UITableViewCell#>)

我不明白从哪里调用索引路径.我需要制作一个单独的NSIndexPath来传递吗?我也不太了解它应该存在的位置 – 以前,它是FirebaseTableViewDatasource,我会在我的viewDidLoad中设置它,它会直接创建单元格等.现在几乎看起来它需要存在于我的cellForRowATindexPath中.有没有人对此有任何建议?

解决方法

这个最新版本的 test使用了一个tableView:bind:方法(看起来像是他们制作的UITableView类扩展),我能够让它工作.

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    let firebaseRef = FIRDatabase.database().reference().child(/*insert path for list here*/)

    let query = firebaseRef.queryorderedByKey() /*or a more sophisticated query of your choice*/

    let datasource = self.tableView.bind(to: query,populateCell: { (tableView: UITableView,indexPath: IndexPath,snapshot: FIRDataSnapshot) -> UITableViewCell in

        let cell = tableView.dequeueReusableCell(withIdentifier: "cellIdentifier",for: indexPath)

        let value = snapshot.value as! NSDictionary

        let someProp = value["someProp"] as? String ?? ""

        cell.textLabel?.text = someProp

        return cell
    })
}

还要确保您正在查看更改的查询,否则将不会填充tableView

self.query?.observe(.value,with: { snapshot in
})

大佬总结

以上是大佬教程为你收集整理的新的FUITableViewDataSource – 如何使用?斯威夫特3全部内容,希望文章能够帮你解决新的FUITableViewDataSource – 如何使用?斯威夫特3所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。