swift - 为什么 BarButton 会转到 View 底部?

标签 swift uinavigationcontroller storyboard viewcontroller

我有一个 ViewController。应用程序中有一个 NavigationController。当我将 Bar Button Item 拖到导航栏时,该项目通常会到达 ViewController 的底部。虽然在过去,我设法让它固定在右上角,它应该去的地方。

知道为什么这有时有效有时无效吗?还有,为什么会掉到底部?走到底部不遵循 HIG。

enter image description here

最佳答案

确保您的 ViewController 在 NavigationViewController 下。

然后,您必须首先将导航项插入导航栏,然后添加您的 BarButtonItem。我看到在 Interface Builder 中,我们只能在左侧添加 1 个 BarButtonItem,在右侧添加 1 个 BarButtonItem。

关于swift - 为什么 BarButton 会转到 View 底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29565454/

相关文章:

swift - 标签栏 Controller 干扰导航栏

swift - 你能让一个类的所有对象通过一个方法调用做同样的事情吗?

ios - Swift .insert 在数据库条目中

ios - Swift 计算属性不能在 init 中使用?

ios - 通用应用程序和在 ios 中转换 Storyboard的最佳方式是什么

ios - UIAppearance 色调颜色优先于 Storyboard 色调颜色

swift - iOS 8 : MapKit's rotateEnabled toggling not working right away

ios - 依赖项注入(inject)通用结构,而无需重新指定占位符类型或约束

ios - 如何使UINavigationBar背景透明?

iphone - UINavigationBar 弹出和弹出而不是滑动