简体   繁体   English

Xcode在Storyboard中使用推送通知打开特定视图

[英]Xcode open specific view with push notifications in storyboard

In my codes, I wrote it in this way 在我的代码中,我是这样写的

DetailView *vc = (DetailView *)[mainStoryboard instantiateViewControllerWithIdentifier:@"DetailVC"];

self.window.rootViewController = vc;

It only show that view but I don't see the navigational bar and tab bar. 它仅显示该视图,但看不到导航栏和标签栏。

What is the right way to open a specific view (inside tabbarcontroller) within storyboard when the app receive remote notifications automatically? 当应用程序自动接收到远程通知时,在情节提要中打开特定视图(在tabbarcontroller内部)的正确方法是什么?

That's because you get only DetailView from storyboard. 那是因为您从情节DetailView仅获得DetailView If you want to show it inside navigation controller you have to init this controller. 如果要在导航控制器中显示它,则必须初始化此控制器。

DetailView *vc = (DetailView *)[mainStoryboard instantiateViewControllerWithIdentifier:@"DetailVC"];
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController: vc];
self.window.rootViewController = navVC;

But I think the issue is in other. 但我认为问题出在其他方面。 You instantiate wrong view controller. 您实例化了错误的视图控制器。 You should instantiate tab bar controller or navigation controller and then only select proper tab. 您应该实例化选项卡栏控制器或导航控制器,然后仅选择适当的选项卡。

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

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