以编程方式更改 viewController

发布于 2024-09-15 03:46:11 字数 855 浏览 9 评论 0原文

从我的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ペ泪落弦音 2024-09-22 03:46:11

想通了。这有帮助。

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文