简体   繁体   English

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

[英]How to push a view controller onto navigation stack AFTER executing popToRootViewController

I am trying to push a new view controller onto a navigation stack only after I pop the stack to rootviewcontroller 我只是在将堆栈弹出到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 ie no new page was displayed. 推送无效,即没有显示新页面。 It seemed that the popToRootViewController causes this to happen (not sure exactly). 似乎popToRootViewController导致这种情况发生(确切地说不确定)。 Any advise on how I can pop and then push a new page? 关于如何弹出然后推新页面的任何建议?

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];

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

相关问题 以编程方式推送至导航堆栈中的视图控制器[2],然后展开至[1] - Programmatically push to view controller [2] in a navigation stack, and unwind to [1] 如何管理潜在的无限推动视图控制器到导航控制器堆栈? iOS版 - How can I manage the potential endless pushing of view controllers onto the navigation controller stack? iOS push segue后使用导航堆栈删除视图控制器(使用Storyboard segues) - Remove view controller from navigation stack after push segue (using Storyboard segues) 例外:无法识别的选择器…尝试在导航堆栈上推送视图控制器时 - Exception: unrecognized selector … when trying to push a view controller on Navigation stack 而不是 push segue 如何替换视图控制器(或从导航堆栈中删除)? - Instead of push segue how to replace view controller (or remove from navigation stack)? 如何在导航堆栈中识别以前的视图 controller - How to identify previous view controller in navigation stack 导航控制器推送视图控制器 - Navigation Controller Push View Controller 无法将视图推入堆栈 - Can't push view onto stack iOS:关闭视图控制器并推送新视图,而不在导航堆栈中显示当前视图 - iOS: Dismiss view controller and push new view without showing the current view in navigation stack 弹出以查看导航堆栈中的控制器 - Pop to view controller in navigation stack
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM