我有以下storyboard
我现在想要的是,当我得到push notification
时,我应该转到tabbarController
内的某个标签页。
我现在想知道实现这一目标的最佳做法是什么?
我可以将self.window.rootController
设置为正确的ViewController
但是当用户按下注销时我遇到了问题。当他按下注销时,他应该被重定向到第一个ViewController。你最左边看到的那个。
有人可以帮我这个吗?
由于
答案 0 :(得分:1)
试试这个:
- (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];
}