我有以下 Storyboard
我现在想要的是,当我收到一个推送通知
时,我应该转到我的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/