大佬教程收集整理的这篇文章主要介绍了新的FUITableViewDataSource – 如何使用?斯威夫特3,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
self.datasource = FUITableViewDatasource(query: <#T##FIRDatabaseQuery#>,view: <#T##UITableView#>,populateCell: <#T##(UITableView,IndexPath,FIRDataSnapshot) -> UITableViewCell#>)
我不明白从哪里调用索引路径.我需要制作一个单独的NSIndexPath来传递吗?我也不太了解它应该存在的位置 – 以前,它是FirebaseTableViewDatasource,我会在我的viewDidLoad中设置它,它会直接创建单元格等.现在几乎看起来它需要存在于我的cellForRowATindexPath中.有没有人对此有任何建议?
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,请注明来意。