从didReceiveRemoteNotification加载storyboard viewcontroller

时间:2014-12-03 09:17:44

标签: ios objective-c iphone xcode ios7

我使用过故事板。该应用程序是基于标签栏控制器。

点击推送通知后,我想从故事板中打开特定的“通知事件”视图控制器。“ 我不知道代码会进入didReceiveRemoteNotification

这里我的代码是:

NSString *notification = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];

Dashboard *ds = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"Dashboard"] ;
NotificationTable *nt = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"NotificationBoard"] ;

UIStoryboardSegue *segue = [UIStoryboardSegue segueWithIdentifier:@"NotificationBoardTable"
                                                           source:ds
                                                      destination:nt
                                                   performHandler:^{
                                                   }];

[ds performSegueWithIdentifier:@"NotificationBoardTable" sender:ds];

1 个答案:

答案 0 :(得分:1)

让我们看看这是否是你想要的:

[[NSNotificationCenter defaultCenter] postNotificationName:kReceiveNotification object:nil userInfo:YOUR_DATA_PASSING];

然后在自定义标签视图控制器中接收它:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(YOUR_HANDLE_METHOD:) name:kReceiveNotification object:nil];

解除分配时不要忘记删除观察者:

[[NSNotificationCenter defaultCenter] removeObserver:self];

最后在那个方法中:

[self setSelectedIndex:xxx];//If you want to switch tab