Xcode 6.1 中的 Show Segue 中无法选择导航栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25897919/
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 05:35:35  来源:igfitidea点击:

Navigation Bar not selectable in Show Segue, Xcode 6.1

iosiphonexcodexcode6

提问by NameTaken

There are 2 View Controllers in my storyboard, VC_Aand VC_B

我的故事板中有 2 个视图控制器,VC_AVC_B

I have embeded a navigation controller in VC_Awhich is a Table View Controller, I then control drag the Prototype Cell into VC_Bto create a segue. If I select "show"in "selection segue" then in VC_BI can see the outline of the navigation bar but I am unable to select it or add any bar buttons to it, it also doesn't appear in the hierarchical view.

我在VC_A 中嵌入了一个导航控制器,它是一个表视图控制器,然后我控制将原型单元拖入VC_B以创建一个 segue。如果我"show"在“selection segue”中选择,然后在VC_B 中我可以看到导航栏的轮廓,但我无法选择它或向其中添加任何栏按钮,它也不会出现在分层视图中。

view

看法

However if I select the "push (deprecated)"option when choosing the type of segue, I am able to select the navigation bar in VC_Band add buttons to it, it also show up in the hierarchical view as a Navigation Item.

但是,如果我"push (deprecated)"在选择 segue 类型时选择该选项,则可以在VC_B 中选择导航栏并向其添加按钮,它也会在分层视图中显示为导航项。

The only work around I can find is to choose show, then change the segue to push(deprecated)in the Attribute Inspector so the Navigation Item will show up in the hierarchical view, then change the segue back to show. But I am worry that this might cause problems further down the line.

我能找到的唯一解决方法是选择show,然后push(deprecated)在属性检查器中将 segue 更改为,以便导航项将显示在分层视图中,然后将 segue 更改回show. 但我担心这可能会导致进一步的问题。

Is there a way to add a Bar Button to VC_B's navigation bar without using the work around?

有没有办法在不使用变通方法的情况下将 Bar Button 添加到VC_B的导航栏?

回答by Sai Jithendra

Just drag the "Navigation Item" from object library to the navigation bar and it should work as expected. You can make changes as you like and it works exactly like in Xcode 5.

只需将“导航项”从对象库拖到导航栏,它就会按预期工作。您可以随心所欲地进行更改,它的工作方式与 Xcode 5 中的完全一样。

回答by Venzentx

Interestingly, when you first time made the connection b/w your table view controllerand view controllerusing Pushyou can start editing the navigation bar without a problem (e.g put bar items onto it).

有趣的是,当您第一次使用Push表格视图控制器视图控制器进行黑白连接时,您可以毫无问题地开始编辑导航栏(例如,将栏项目放在上面)。

Then delete the connection between your table view controllerand view controller(but do not delete the nav bar items you just added), then re-connect the two controllers by using segue Show, you will see the navigation bar works just like segue Pushnow.

然后删除你的table view controllerview controller之间的连接(但不要删除你刚刚添加的导航栏项目),然后使用segue Show重新连接两个控制器,你会看到导航栏现在就像segue push一样工作.

Hope it helps

希望能帮助到你

回答by Snaker

I think the way you do it (going through the deprecated push) is not wrong even though there's another way. In fact, when you turn the Segue into a push, you get a Navigation Item out of it.

我认为您这样做的方式(通过已弃用的推送)并没有错,即使有另一种方式。事实上,当您将 Segue 转换为推送时,您会从中获得一个导航项。

So all you have to do is add a Navigation Item to your View Controller and that'll do the trick:

所以你所要做的就是在你的视图控制器中添加一个导航项,这样就可以了:

enter image description here

在此处输入图片说明

回答by Joni

This seems Xcode bugs.

这似乎是 Xcode 错误。

In my case, i am re-create segue by this sequence:

就我而言,我按以下顺序重新创建 segue:

  1. Delete existing seque. (I am using "Action segue - Show")
  2. Drag new segue with "Non-Adaptive Action Segue - Push (deprecated)"
  3. Delete segue no.2
  4. Re-create/connect "Action Seque - Show". (No.1)
  5. Done
  1. 删除现有序列。(我正在使用“动作转场 - 显示”)
  2. 使用“Non-Adaptive Action Segue - Push (deprecated)”拖动新的 segue
  3. 删除segue 2
  4. 重新创建/连接“动作序列 - 显示”。(第一)
  5. 完毕

Now, i can edit navigation title and add custom navigation item button as usually.

现在,我可以像往常一样编辑导航标题并添加自定义导航项按钮。

I am using Xcode 6.4, and minimal target iOS version 7.

我使用的是 Xcode 6.4 和最低目标 iOS 版本 7。

回答by user3722523

In your viewController :

在您的 viewController 中:

self.navigationItem.title = "Second VC"
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Play, target: self, action: "playFunction:")

enter image description here

在此处输入图片说明