以编程方式更改 viewController
从我的navigationController我有两条路径:
navigationController --> ViewControllerA - ViewControllerB(当前显示)。
和导航控制器 --> ViewController1 --> ViewController2。
我想从 ViewControllerB 转到 ViewController2。
这是我尝试过的:
[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];
self.navigationController PushViewController 不起作用。
我在应用程序委托中引用了 viewController1 并尝试了 [app.viewController1 PushViewControleranimated:YES]; ,但这也不起作用。
你如何解决这个问题?
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 and tried [app.viewController1 pushViewControler animated:YES];, but that doesn't work either.
How do you solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了。这有帮助。
http://discussions.apple.com/thread.jspa? threadID=2305421&tstart=0#10929636
显然,如果您将另一个视图控制器推到 poptorootviewcontroller 之上,则无法对其进行动画处理。
谢谢!
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!