【问题标题】:Add a right button to a nested view in a UINavigation stacking using Storyboards使用 Storyboard 向 UINavigation 堆叠中的嵌套视图添加右键
【发布时间】:2019-09-02 10:09:33
【问题描述】:

假设我们在 UINavigationController 中嵌入了一个 UIViewControllerUIViewController 与另一个 UIViewController 连接。

第二个UIViewController 具有标准的左侧导航按钮,可以“展开”到前一个UIViewController

我似乎无法通过情节提要向第二个UIViewController 的导航栏添加右侧按钮(使用UIBarButtonItem),当我尝试这样做时,按钮最终会在UIViewController 的底部(见下文,请注意左侧按钮丢失)。我缺少什么技巧吗?

我可以将第二个 UIViewController 嵌入到它自己的 UINavigationController 中,但是我失去了后退按钮的功能。

我知道可以在代码中添加按钮,所以如果我尝试一些不可能的事情,一切都不会丢失。

【问题讨论】:

  • 如果您使用的是 UIButton,请尝试使用 UIBarButtonItem。
  • 我应该更清楚...我正在使用 UIBarButton
  • 尝试先添加一个 UINavigationItem。

标签: ios swift uinavigationcontroller uinavigationbar uistoryboard


【解决方案1】:

要在情节提要中执行此操作,您需要将 UINavigationItem 放在您的 UIViewController 上。然后你可以添加你的UIBarButtonItem(s)。

【讨论】:

    猜你喜欢
    • 2014-09-26
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多