【发布时间】:2016-05-20 23:23:52
【问题描述】:
当应用程序打开或在后台时,我正在使用appdelegate 中的通知来更新消息框表,然后它就可以工作了。
Appdelegate(在 didFinishLaunchingWithOptions 和 didReceiveRemoteNotification 中):
NSNotificationCenter.defaultCenter().postNotificationName("changeMessageBox", object: nil)
MessageViewController:
在viewdidload:
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector (MessagesViewController.reloadtable), name: "changeMessageBox", object: nil)
func reloadtable()
{
clearArrays()
if (PFUser.currentUser()!["firebaseUID"] !== nil)
{
self.updateResultArray(PFUser.currentUser()!["firebaseUID"] as! String)
resultsTable.reloadData()
}
}
消息框中的数据会刷新。
但是当应用程序关闭并且我收到聊天时,消息框(包含来自所有人而不是个人聊天的消息的窗口)不会更新。
我必须打开应用程序,转到消息框,然后返回主页并再次返回消息框,然后表格视图才会刷新。
你们知道我错过了什么吗?
【问题讨论】:
标签: ios swift uitableview firebase