Programmatically changing viewControllers
From my navigationController I have two paths:
navigationController --> ViewControllerA -- ViewControllerB (currently showing).
and navigationController --> ViewController1 -->ViewController2.
I want to go from ViewControllerB to ViewController2.
Here's what I tried:
[self.navigationController popToRootViewControllerAnimated:YES]; // Works fine
AppDelegate app* = [[UIApplication sharedApplication] delegate];
LocationsViewController* locationsViewController = [[LocationsViewController alloc] initWithNibName:@"LocationsView" bundle:nil];
locationsViewController.title = @"Title";
[self.navigationController pushViewController:locationsViewController animated:YES];
The self.navigationController pushViewController doesn't work.
I have a reference to viewController1 in App delegate a开发者_运维百科nd tried [app.viewController1 pushViewControler animated:YES];, but that doesn't work either.
How do you solve this problem?
Figured it out. This helped.
http://discussions.apple.com/thread.jspa?threadID=2305421&tstart=0#10929636
Apparently, the poptorootviewcontroller can't be animated, if you're pushing another view controller on top of it.
Thanks!
精彩评论