我正在尝试为我的应用中的用户制作收件箱。但是我在重新加载tableView时遇到了问题。如果我删除self.tabelView.reloadData()
应用视图运行正常,但当然不会更新表格单元格。查询确实成功,因为我可以打印出结果数组。我得到的是一个LLDB错误。它声明“EXC_BreakPoint”,我没有设置任何断点。这是我的代码:
class InboxTableViewController: UITableViewController {
var pinggedUser: String!
var toBeUserId: String!
let dataBase = FIRDatabase.database()
var SecondResultArray: [FIRDataSnapshot]! = []
override func viewDidLoad() {
messageReference = rootReference.child("messages")
//let UserRef = messageReference.child((FIRAuth.auth()?.currentUser?.displayName)!)
messageReference.queryOrderedByChild("senderName")
.observeSingleEventOfType(.Value, withBlock:{ snapshot in
for child in snapshot.children {
self.SecondResultArray.append(child as! FIRDataSnapshot)
//print(self.ResultArray)
}
print(self.SecondResultArray )
self.tableView.reloadData()
})
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return SecondResultArray.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("inboxCell", forIndexPath: indexPath)
// Configure the cell...
let inBox: FIRDataSnapshot! = self.SecondResultArray[indexPath.row]
let book = inBox.value as! Dictionary<String, String>
let receiver = book["receiver"] as String!
let senderId = book["senderId"] as String!
let messageText = book["text"] as String!
let senderName = book["senderName"] as String!
cell.textLabel?.numberOfLines = 0
cell.textLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping
cell.textLabel?.text = "Your Messages With:" + "" + senderName
return cell
}
}
答案 0 :(得分:0)
你可能没有注册你的桌面视图。
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")