我在 Storyboard的 Interface Builder 中有一个 UINavigationController
。我已将两个 UIBarButtonItems
添加到第一个 UIViewController
中。它们显示得很好。如何将它们添加到导航到的第二个 UIViewController
中?在该 View Controller 上,我只看到“后退”按钮。
当我尝试将 UIBarButtonItem
拖动到第二个 View Controller 的顶部时,该按钮由于某种原因最终出现在场景的底部。运行应用程序时不显示。
编辑:我应该提到我知道如何在代码中执行此操作,但不知道如何在 Interface Builder 中执行此操作。
最佳答案
添加有关我对导航项的评论的更多信息:
这是一个简单的项目,其中 UIViewController
嵌入到 UINavigationController
中。可以通过“下一步”按钮推送第二个 UIViewController
。
如果选择下一个按钮,您可以在层次结构中看到该按钮嵌入在 Right Bar Buttons Items
组中,该组嵌入在 First
对象中。事实上,First
是一个 UINavigationItem
,当它嵌入到导航 Controller 中时,会自动添加到 View Controller 中。
但是第二个 View Controller (推送的 View Controller )没有此导航项,因为它没有直接嵌入到导航 Controller 中。只需将其从对象库拖放到您的 View Controller 即可。
关于ios - 将 Interface Builder 中的 UIBarButtonItem 添加到导航的 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35620633/