[英]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.