刚刚更新到更新的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 })
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。