xcode 在 Storyboard 上的第二个 ViewController 中无法访问 iOS 8 导航栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27243361/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:17:42  来源:igfitidea点击:

iOS 8 Navigation Bar Not Accessible in Second ViewController on Storyboard

iosxcodeuiviewcontrolleruinavigationcontrolleruinavigationbar

提问by Daniel E

I am new to iOS development and have not tried this programmatically yet. I would prefer to get this working in a storyboard.

我是 iOS 开发的新手,还没有以编程方式尝试过。我更愿意让它在故事板中工作。

I'm following this somewhat outdated tutorial from XCode 4.5 in XCode 6.1 to create a series of views connected by one navigation controller. http://youtu.be/rgd6mCuzlEc

我正在遵循 XCode 6.1 中 XCode 4.5 的这个有点过时的教程来创建一系列由一个导航控制器连接的视图。 http://youtu.be/rgd6mCuzlEc

Screenshot

截屏

Once I create the second view controller, I am unable to double click the navigation bar to change the name and I am unable to add a bar button to it.

创建第二个视图控制器后,我无法双击导航栏来更改名称,也无法向其添加栏按钮。

I have a Segue going from bar button "Item" from view 1 to 2. Notice in the "View Controller Scene" there is no navigation item. If I add any elements to the view controller they fall under "View" and not under "View Controller", unlike view controller 1 where it falls under "one".

我有一个从栏按钮“项目”从视图 1 到 2 的 Segue。注意在“视图控制器场景”中没有导航项。如果我向视图控制器添加任何元素,它们将属于“视图”而不是“视图控制器”,这与它属于“一”的视图控制器 1 不同。

Is this a limitation on XCode? Am I using the wrong Segue (Show)? Is there a hidden setting or customization I'm missing?

这是对 XCode 的限制吗?我是否使用了错误的 Segue (Show)?是否有我遗漏的隐藏设置或自定义设置?

I actually have this working for 2 view controllers and failing the 3rd in a separate project but I don't know what I did to do that so I'm pretty sure it's possible I just cannot reproduce..

我实际上有这个适用于 2 个视图控制器,并且在一个单独的项目中第 3 个失败,但我不知道我做了什么,所以我很确定我可能无法重现..

EDIT:WorkaroundInstead of the new adaptive SHOW segue, use the deprecated PUSH segue, add the bar button items, then change back to the adaptive SHOW segue.

编辑:解决方法代替新的自适应 SHOW segue,使用已弃用的 PUSH segue,添加条形按钮项,然后改回自适应 SHOW segue。

回答by KristofferArl

Try adding a Navigation Item to the controller and it should work properly

尝试向控制器添加导航项,它应该可以正常工作

enter image description here

在此处输入图片说明