繁体   English   中英

从didReceiveRemoteNotification加载情节提要ViewController

[英]load storyboard viewcontroller from didReceiveRemoteNotification

我已经使用了情节提要。 该应用程序基于标签栏控制器。

单击推送通知后,我想从情节提要中打开特定的“ Notification Event”视图控制器。”我不知道在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];

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

[[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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM