Ios 不使用firebase在tableview中显示自定义单元格
我正在使用Xcode和Firebas*。单击post按钮时,它会将数据保存到Firebase,并将您带到Ios 不使用firebase在tableview中显示自定义单元格,ios,uitableview,firebase,firebase-realtime-database,Ios,Uitableview,Firebase,Firebase Realtime Database,我正在使用Xcode和Firebas*。单击post按钮时,它会将数据保存到Firebase,并将您带到UITableView。但由于某些原因,UITableViewCell未显示。我不知道为什么自定义单元格没有显示。为单元格创建自定义类,并将其链接到标识符。单元格上的内容是一个ui标签。为什么UITableViewCell不显示来自Firebase的数据 import Foundation import Firebase class TableViewController: UIViewCo
UITableView
。但由于某些原因,UITableViewCell
未显示。我不知道为什么自定义单元格没有显示。为单元格创建自定义类,并将其链接到标识符。单元格上的内容是一个ui标签
。为什么UITableViewCell
不显示来自Firebase的数据
import Foundation
import Firebase
class TableViewController: UIViewController,UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var OpenPost: UIButton!
let storiesRef = Database.database().reference().child("People").child("HomeFeed").child("Posts")
var stories = [Story]()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// download stories
storiesRef.observe(.value, with: { (snapshot) in
self.stories.removeAll()
for child in snapshot.children {
let childSnapshot = child as! DataSnapshot
let story = Story(snapshot: childSnapshot)
print(story)
self.stories.insert(story, at: 0)
}
self.tableView.reloadData()
})
}
override func viewDidLoad()
{
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
// MARK: - Table view data source
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return stories.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "Story Cell", for: indexPath) as! StoryTableviewcell
let story = stories[indexPath.row]
cell.story = story
return cell
}
}
检查你的“故事单元”标识符是否正确检查字母表你的点击方法在哪里?firebase和tableview与上述问题没有联系,我认为你在某些地方犯了一个小错误,你只能跟踪问题所在。放置断点并检查stories.count值。