如何在执行 popToRootViewController 后将视图控制器推送到导航堆栈上

发布于 2024-12-07 10:59:19 字数 675 浏览 0 评论 0原文

仅在将堆栈弹出到 rootviewcontroller 后,我才尝试将新的视图控制器推送到导航堆栈上。

//Select the tab I want to go to
self.tabBarController.selectedIndex = FEEDPAGE_INDEX;

//Retrieve the navcon in the feed page
UINavigationController *navcon = (UINavigationController*)[self.tabBarController.viewControllers objectAtIndex:FEEDTAB_INDEX];

//Pop to root view controller here
[navcon popToRootViewControllerAnimated:YES];

//Push a new root view controller onto stack
QuestionAnswerViewController *x = [[QuestionAnswerViewController alloc]init];
[navcon pushViewController:x animated:YES];

推送不起作用,即没有显示新页面。似乎是 popToRootViewController 导致这种情况发生(不确定)。关于如何弹出然后推送新页面有什么建议吗?

I am trying to push a new view controller onto a navigation stack only after I pop the stack to rootviewcontroller

//Select the tab I want to go to
self.tabBarController.selectedIndex = FEEDPAGE_INDEX;

//Retrieve the navcon in the feed page
UINavigationController *navcon = (UINavigationController*)[self.tabBarController.viewControllers objectAtIndex:FEEDTAB_INDEX];

//Pop to root view controller here
[navcon popToRootViewControllerAnimated:YES];

//Push a new root view controller onto stack
QuestionAnswerViewController *x = [[QuestionAnswerViewController alloc]init];
[navcon pushViewController:x animated:YES];

The push didn't work i.e. no new page was displayed. It seemed that the popToRootViewController causes this to happen (not sure exactly). Any advise on how I can pop and then push a new page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伏妖词 2024-12-14 10:59:19
QuestionAnswerViewController *x = [[QuestionAnswerViewController alloc]init];
UINavigationController *navcon = (UINavigationController*)[self.tabBarController.viewControllers objectAtIndex:FEEDTAB_INDEX];
NSArray *arr = [navcon viewControllers];
NSArray *newStack = [NSArray arrayWithObjects:[arr objectAtIndex:0], x, nil];
[navcon setViewControllers:newStack];
QuestionAnswerViewController *x = [[QuestionAnswerViewController alloc]init];
UINavigationController *navcon = (UINavigationController*)[self.tabBarController.viewControllers objectAtIndex:FEEDTAB_INDEX];
NSArray *arr = [navcon viewControllers];
NSArray *newStack = [NSArray arrayWithObjects:[arr objectAtIndex:0], x, nil];
[navcon setViewControllers:newStack];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文