ios - 如何在导航栏上放置一个栏按钮

标签 ios xcode

我正在关注this tutorial ,我正在尝试添加一个“栏按钮”。该教程内容如下:

While you’re there, change the title of the screen to Add Player (by double-clicking in the navigation bar). Also add two Bar Button Items to the navigation bar. In the Attributes inspector, set the Identifier of the button to the left to Cancel, and the one on the right to Done (also change this one’s Style from Bordered to Done).

我按照步骤操作,但每次我拖动“条形按钮”将其放置在导航栏上时,它会自动移动到场景的左下方,如图 1 所示

请让我知道以下内容

1-如何在导航栏上放置栏按钮

2-如何将“ Root View Controller ”重命名为“添加玩家”

image-1:

enter image description here

最佳答案

在 Storyboard中禁用 NavigationController 的 navigationBar 的半透明属性。

如果您启用了半透明,那么您不能将栏项目拖动到导航栏。

enter image description here

现在您可以通过 Storyboard将 Bar item 拖到 Navigation bar。

结果 enter image description here

关于ios - 如何在导航栏上放置一个栏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44304031/

相关文章:

ios - locationManager 在 Swift 3 中被弃用了吗?

ios - Launchimage 和 Appicon 未添加到 Xcode 8.3.3 中的 assets.xcassets

iphone - 如何删除 _UIAlertNormalizingOverlayWindow

ios - IMDB API 中的 lldb 错误

xcode - 无法在框架内加载 Assets

ios - 在 El Capitan 上安装 Xcode 8 beta 2 时扩展 Xcode

ios - uiTableViewCell 添加行和图像,第二次点击删除行

iOS 核心数据迁移超时

ios - 如何判断 child 是否为零

24 小时格式的 iOS 时间