开发者

Programmatically changing viewControllers

开发者 https://www.devze.com 2023-01-12 10:36 出处:网络
From my navigationController I have two paths: navigationController --> ViewControllerA -- ViewControllerB (currently showing).

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消