我有以下storyboard
我现在想要的是,当我收到push notification
时,应该转到tabbarController
内的某个选项卡。
我现在想知道实现此目标的最佳实践是什么?
我可以将self.window.rootController
设置为正确的ViewController
,但是当用户按下注销时出现问题。当他按下注销时,应该将他重定向到第一个ViewController。您在最左侧看到的那个。
有人可以帮我吗?
谢谢
最佳答案
尝试这个 :
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if (self.window.rootViewController.presentedViewController != nil)
{
[self.window.rootViewController.presentedViewController dismissViewControllerAnimated:YES completion:^{
{
UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
tabbarcontroller=[storyboard instantiateViewControllerWithIdentifier:@"Tabbar"];
[tabbarcontroller setSelectedIndex:1];
[self.window.rootViewController presentViewController:tabbarcontroller animated:YES completion:nil];
}
UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
tabbarcontroller=[storyboard instantiateViewControllerWithIdentifier:@"Tabbar"];
[tabbarcontroller setSelectedIndex:1];
[self.window.rootViewController presentViewController:tabbarcontroller animated:YES completion:nil];
}];
UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
tabbarcontroller=[storyboard instantiateViewControllerWithIdentifier:@"Tabbar"];
[tabbarcontroller setSelectedIndex:1];
[self.window.rootViewController presentViewController:tabbarcontroller animated:YES completion:nil];
}
关于ios - 接收推送通知时转到tabbarcontroller中的某个选项卡,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23800342/