我正在尝试做一个小使者,我想显示一条警告消息,指出除了谈话本身。现在,我的警报随处显示,是否可以过滤它,以便它不显示在ConversationDetailController上?如何在iOS推送通知后显示UIAlertView,除了在一个视图中
这是我在的appdelegate代码
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
var mess:String?
var displayName:String?
if let result = userInfo["aps"] as? NSDictionary {
if let alert = result["alert"] as? String {
mess = alert
if let extra = userInfo["extra"] as? NSDictionary
{
if let name = extra["displayName"] as? String
{
displayName = name
var alert = UIAlertView(title: "You have a new message from \(displayName!)", message: mess, delegate: nil, cancelButtonTitle: "OK")
alert.show()
}
}
NSNotificationCenter.defaultCenter().postNotificationName("newMessageReceived", object: nil)
}
}
}
你的视图控制器是如何呈现的?对你的问题最简单的解决方案是检查self.window.rootViewController,但如果你使用容器(如UITabBarController或UINavigationController),这将不是你正在寻找的viewController – chedabob
My ConversationDetailTableViewController嵌入在UINavigationController不幸的是:/ –