modalviewcontroller 推送想要关闭的视图控制器

发布于 2024-12-18 22:40:16 字数 880 浏览 1 评论 0原文

所以我创建了一个模态视图控制器,它有一个像这样的导航栏......

PurchaseSelectVendor *selectVendor = [[PurchaseSelectVendor alloc] initWithNibName:@"PurchaseSelectVendor" bundle:nil ];
        UINavigationController *modalNavController = [[UINavigationController alloc] initWithRootViewController:selectVendor];
        [selectVendor release];
        [self presentModalViewController:modalNavController animated:YES];
        [modalNavController release];

然后模态视图将推送另一个视图控制器。 (我们将其称为视图 2)

PurchaseNewItems *newItemsController = [[PurchaseNewItems alloc] initWithNibName:@"PurchaseNewItems" bundle:nil];
[[self navigationController] pushViewController:newItemsController animated:YES];
[newItemsController release];

视图 2 有一个带有完成按钮的导航栏。当用户点击“完成”按钮时,我希望它关闭到首先呈现模式视图的视图。

我尝试的所有操作都只是将视图 2 退回到呈现它的 madalview 。

实现这一目标的正确方法是什么?

So I've created a modalviewcontroller that has a navigation bar like so...

PurchaseSelectVendor *selectVendor = [[PurchaseSelectVendor alloc] initWithNibName:@"PurchaseSelectVendor" bundle:nil ];
        UINavigationController *modalNavController = [[UINavigationController alloc] initWithRootViewController:selectVendor];
        [selectVendor release];
        [self presentModalViewController:modalNavController animated:YES];
        [modalNavController release];

The modal view will then push another view controller. (We'll call it view 2)

PurchaseNewItems *newItemsController = [[PurchaseNewItems alloc] initWithNibName:@"PurchaseNewItems" bundle:nil];
[[self navigationController] pushViewController:newItemsController animated:YES];
[newItemsController release];

view 2 has a navigation bar with a done button. When the user taps the done button I want it to dismiss to the view that presented the modal view in the first place.

Everything I try just dismisses view 2 back to the madalview that presented it.

What is the proper way to accomplish this?

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

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

发布评论

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

评论(1

油焖大侠 2024-12-25 22:40:16

在 iOS 5 中,PurchaseNewItems 控制器需要告诉其 parentViewControllerpresentingViewController 关闭模态视图控制器。 (您不能再将模态视图的呈现者称为模态视图控制器的parentViewController。)

In iOS 5, the PurchaseNewItems controller needs to tell its parentViewController's presentingViewController to dismiss the modal view controller. (You can no longer refer to the presenter of a modal view as the modal view controller's parentViewController.)

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