【发布时间】:2015-11-12 18:32:21
【问题描述】:
我想在表格视图中显示多个(远程)通知。 我的问题是,只显示一条消息。
在我的 AppDelegate.swift 我有这个:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let rVC = storyboard.instantiateViewControllerWithIdentifier("PushVC")
let push = rVC as! PushVC
self.window!.rootViewController = rVC
if let aps = userInfo["aps"] as? NSDictionary {
if let alert = aps["alert"] as? NSDictionary {
if let message = alert["message"] as? NSString {
push.addPushNote(message as String)
}
} else if let alert = aps["alert"] as? NSString {
push.addPushNote(alert as String)
}
}
}
addPushNote 是我的 ViewController 中向表格视图添加新通知的方法:
public func addPushNote(message: String){
pushNotes.append(message)
table.reloadData()
print(message)
}
当收到多条消息时, print(message) 会显示所有消息 - 但只显示第一条消息。 我怀疑,对于每个推送通知,消息都会添加到 PushVC 的不同实例中。
任何帮助将不胜感激。
【问题讨论】:
-
如何加载表格视图的其余部分?还是您只希望有一个条目?
标签: ios swift notifications apple-push-notifications tableview