gpt4 book ai didi

ios - 从 didReceiveRemoteNotification 加载 Storyboard View Controller

转载 作者:行者123 更新时间:2023-11-29 02:27:59 24 4
gpt4 key购买 nike

我使用了 Storyboard。该应用程序是基于标签栏 Controller 的。

单击推送通知时,我想从 Storyboard打开特定的“通知事件” View Controller 。”我不知道 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];

然后在您的自定义选项卡 View Controller 中接收它:

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

关于ios - 从 didReceiveRemoteNotification 加载 Storyboard View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27267720/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com