正如标题所暗示的:当用户通过滑动推送通知启动应用时,如何打开特定的视图控制器?
谢谢!
答案 0 :(得分:3)
执行以下操作,
在您的应用主视图控制器" viewDidLoad"方法添加观察者,
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "SomeNotificationAct:",
name: "SomeNotification",
object: nil)
并添加方法
func SomeNotificationAct(notification: NSNotification){
dispatch_async(dispatch_get_main_queue()) {
self.performSegueWithIdentifier("NotificationView", sender: self)
}
}
并在" didReceiveRemoteNotification"中添加以下代码App的appdelegate类的方法
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){
NSNotificationCenter.defaultCenter().postNotificationName("SomeNotification", object:nil, userInfo:someData)
}