modalviewcontroller 推送想要关闭的视图控制器
所以我创建了一个模态视图控制器,它有一个像这样的导航栏......
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 iOS 5 中,PurchaseNewItems 控制器需要告诉其
parentViewController
的presentingViewController
关闭模态视图控制器。 (您不能再将模态视图的呈现者称为模态视图控制器的parentViewController。)In iOS 5, the PurchaseNewItems controller needs to tell its
parentViewController
'spresentingViewController
to dismiss the modal view controller. (You can no longer refer to the presenter of a modal view as the modal view controller'sparentViewController
.)