如何在 modalViewController 上推送 UIVIewController?

发布于 2024-12-17 14:02:05 字数 343 浏览 2 评论 0原文

我有标签栏+导航应用程序。我打电话给filterModalController:

[self.navigationController presentModalViewController:filterModalController animated:YES];

看起来没问题。然后我想推送officeController。

[self.navigationController pushViewController:officeController animated:YES];

但officeController并没有出现。怎么了?

I have tabbar + navigation app. I call filterModalController:

[self.navigationController presentModalViewController:filterModalController animated:YES];

It appeared OK. Then I want to push officeController.

[self.navigationController pushViewController:officeController animated:YES];

But officeController didn't appeared. What is wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

北风几吹夏 2024-12-24 14:02:05

我的理解是,模态视图控制器并不意味着推动其他视图控制器,因此您可能需要考虑正在使用的视图的层次结构。模态框旨在返回到父视图控制器。您可能需要

[self.navigationController dismissModalViewControllerAnimated:YES];

在推送 officeViewController 之前调用。

当我遇到这个问题时,我最终将导航控制器推为模式视图控制器,并将“filterModalController”作为根视图控制器。由于您已经有一个导航控制器,这可能会让事情变得太混乱。

UINavigationController*  filterNavController = [[UINavigationController alloc] 
                            initWithRootViewController:filterModalController];

// Display the nav controller modally.
[self presentModalViewController:filterNavController animated:YES];

[locationNavController release];

然后 filterNavController 可以推送您的 officeController

My understanding is that modal view controllers are not meant to push other view controllers, so you may want to think about the hierarchy of views you are using. Modals are meant to return to the parent view controller. You may need to call

[self.navigationController dismissModalViewControllerAnimated:YES];

before you push the officeViewController.

When I ran into this, I ended up pushing a Navigation controller as the modal view controller, with the 'filterModalController' as the root view controller. Since you already have a navigation controller, this may make things too confusing.

UINavigationController*  filterNavController = [[UINavigationController alloc] 
                            initWithRootViewController:filterModalController];

// Display the nav controller modally.
[self presentModalViewController:filterNavController animated:YES];

[locationNavController release];

Then the filterNavController can push your officeController.

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