Iphone UIViewController从viewController和后退按钮以模式加载UINavigationController

Iphone UIViewController从viewController和后退按钮以模式加载UINavigationController,iphone,ios,Iphone,Ios,可能重复: 我目前正在开发一款使用故事板(支持IOS 5.1-6)的应用程序。我的rootViewController是一个UIViewController。当显示新内容时,我正在使用segue加载不同的UIViewController。在一个特定视图上,我想加载底部有工具栏的UINavigationController,这样我可以通过点击后退按钮返回到我的UIViewController 我有点困惑,因为在NavigationController上我无法关闭当前的NavigationCont

可能重复:

我目前正在开发一款使用故事板(支持IOS 5.1-6)的应用程序。我的rootViewController是一个
UIViewController
。当显示新内容时,我正在使用segue加载不同的UIViewController。在一个特定视图上,我想加载底部有工具栏的
UINavigationController
,这样我可以通过点击后退按钮返回到我的
UIViewController

我有点困惑,因为在NavigationController上我无法关闭当前的
NavigationController
,因为没有后退按钮。如果我添加后退按钮,我将看不到它,因为
NavigationController
位于堆栈顶部

有没有人能为我指出正确的方向,或者在这里提供一些关于如何关闭这个NavigationController的见解,因为它被称为modally

一如既往,提前感谢您的帮助


谢谢

您需要将
UIBarButtonItem
添加到
UINavigationController
。因为您以模式显示新视图,所以它应该是一个“完成/取消”按钮(取消模式VC),而不是一个“返回”按钮(弹出视图返回)

最初显示模态视图控制器时,可以传递一个dismise块,当按下解除视图控制器的解除按钮时将调用该块

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
这里的关键区别是后退按钮和取消按钮的概念。苹果的HIG文档对此进行了解释