【问题标题】:UIViewController loading a UINavigationController modally from a viewController and a back button [duplicate]UIViewController 从 viewController 和后退按钮模态加载 UINavigationController [重复]
【发布时间】:2012-12-23 01:54:42
【问题描述】:

可能重复:
How to show back button on the RootViewController of the UINavigationController?

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

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

有人可以指出我正确的方向或提供一些关于如何解除此 NavigationController 的见解吗?因为它是模态调用的?

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

谢谢!

【问题讨论】:

    标签: iphone ios


    【解决方案1】:

    您需要将UIBarButtonItem 添加到UINavigationController。因为您正在模态显示新视图,所以它应该是“完成/关闭”按钮(关闭模态 VC)而不是“返回”按钮(将视图弹出回来)。

    当您最初呈现模态视图控制器时,您可以传递一个关闭块,当您按下关闭视图控制器的关闭按钮时将调用该块。

    - (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
    - (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
    

    这里的关键区别是返回按钮与关闭按钮的概念。这在 Apple 的 HIG 文档中进行了解释。

    UIViewController Reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-02
      • 2012-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多