无法在故事板iOS8中的导航栏中添加右栏按钮 [英] Cannot add right bar button in navigation bar in storyboards iOS8

查看:84
本文介绍了无法在故事板iOS8中的导航栏中添加右栏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示,我想知道是否可以通过代码避免在导航栏中添加右栏按钮。



我已经完成了通常的过程,其中一个视图控制器嵌入在导航控制器中,并试图将条形按钮项目放在视图控制器的导航栏中,但由于某些原因它不再起作用。



<那么有可能在iOS 8中以某种方式在故事板中完成吗?



Xcode ver。 6.2稳定

解决方案

好吧,似乎iOS 8中引入的新segue与旧版本之间存在差异。在这种情况下,它是 push segues之间的区别,它允许在storyboard中添加一个正确的栏按钮, show segue,如果自动添加(从控制器拖动到另一个控制器)不允许删除导航栏中的按钮。



原因是使用 segues,控制器会自动给出导航栏,因此你可以添加元素,而如果使用 new segues,导航栏不会自动添加到故事板中的控制器。



为我解决这个问题的原因是:


  1. 选择导致问题的segue控制器

  2. 将其更改为已弃用推送 segue

  3. 将其更改回接受 show segue

结果:现在我可以像往常一样添加正确的栏按钮项目通过Storyboard。


As the title suggests, I would like to know if it is possible to avoid adding right bar button in the navigation bar through code.

I've done the usual process with a view controller embedded in a navigation controller and trying to drop the bar button item inside the navigation bar of the view controller, but it no longer works for some reasons.

So is it possible to be done in the storyboard somehow in iOS 8?

Xcode ver. 6.2 Stable

解决方案

Well, it seems there is a problem with the differences between new segues introduced in iOS 8 and the old ones. In this case it is the difference between push segues which allows adding a right bar button in storyboard and show segue which if added automatically (dragging from a controller to another) does not allow dropping the button in the navigation bar.

The reason is when using the old segues, the controller would automatically be given a navigation bar, thus you can add elements to it, while if using the new segues the navigation bar is not automatically added to the controller in the storyboard.

What solved this issue for me was:

  1. Selecting the segue which leads to the problematic controller
  2. Changing it to the "deprecated" push segue
  3. Changing it back to the accepted show segue

Result: Now I can add as always the right bar button item through Storyboard.

这篇关于无法在故事板iOS8中的导航栏中添加右栏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆