gpt4 book ai didi

ios - 如果我从推送通知启动我的应用程序,为什么我的导航栏会消失?

转载 作者:行者123 更新时间:2023-11-28 22:12:09 24 4
gpt4 key购买 nike

我有一个应用程序,其中有一个包含所有推送通知列表的 subview Controller 。因此,我想在用户从推送通知启动应用程序时加载此 View Controller 。我正在启动正确的 View Controller (NotifcationsViewController),但它不包括它应该具有的导航栏。如果我从 parent 那里启动 Controller ,它只有导航栏。以下代码在我的 appDelegate.m 文件中。

- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

{

if ( application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground  )
{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle: nil];
UINavigationController *nav = [mainStoryboard instantiateViewControllerWithIdentifier:@"NotificationsViewController"];
[_window setRootViewController:nav];

}
}

NotificationsViewController 有/应该有一个左侧导航栏项目,它会弹回到它的 parentViewController。

最佳答案

试试这个

if ( application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground  )
{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle: nil];
UIViewController *viewController= [mainStoryboard instantiateViewControllerWithIdentifier:@"NotificationsViewController"];
UINavigationController *nav = [[UINavigationController alloc]
initWithRootViewController:viewController];
[_window setRootViewController:nav];

}
}

关于ios - 如果我从推送通知启动我的应用程序,为什么我的导航栏会消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22617406/

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