不支持推送导航控制器 - 执行segues [英] Pushing a navigation controller is not supported- performing segues

查看:211
本文介绍了不支持推送导航控制器 - 执行segues的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在故事板中创建了一个新的导航控制器(不是以编程方式!)并将其设置为常规UIViewController的Root View Controller,并在其中添加了一个按钮,表示 - 转发到下一个视图控制器(第二个视图) controller是一个视图控制器,我希望它有一个后退按钮链接到初始视图控制器)。
现在,每当我尝试将按钮链接到下一个视图控制器时 - 不支持推送导航控制器。

I created a new navigation controller in my storyboard (not programmatically!) and set it to be "Root View Controller" to a regular UIViewController and added a button in it which says- forward to the next view controller (this second view controller is a view controller which I want that will have a back button to link to the initial view controller). Now, whenever I try to link the button to the next view controller- "Pushing a navigation controller is not supported".

请帮帮我,谢谢

编辑:
我意外地将UINavigationController子类化,而不是我班级中的UIViewController。
无论如何,谢谢你。

I accidentally subclassed UINavigationController, and not UIViewController in my class. Thank you anyway.

推荐答案

我已经尝试了这个并且没有任何问题,它全部在IB中完成,无需额外的代码...

I've tried this and have no problems, its all done in IB with no additional code required ...


  1. 使用故事板开始一个新项目单一视图应用程序

  2. 选择故事板并删除视图它产生了。

  3. 在新的导航控制器上拖动(它将带来一个表视图)

  4. 删除表和表视图控制器,因此您只需使用导航控制器

  5. 在普通视图控制器上拖动

  6. 右键单击并从导航控制器拖动到新视图和选择关系 - 根视图控制器

  7. 将条形按钮项拖到Navbar上,该视图应该在ViewController的顶部可见,如果需要,可以将其重命名为Forward。

  8. 现在拖动另一个视图控制器,这是您的前进按钮将推入的视图。

  9. 右键单击并从中拖动e栏按钮到第二个视图控制器,然后选择推送

  1. Start a new project, "Single View Application" using story boards
  2. Select storyboard and delete the views its produced.
  3. Drag on a new Navigation Controller (it will bring a table view with it)
  4. Delete the table and the table view controller, so you are just left with the Navigation Controller
  5. Drag on a normal view controller
  6. Right Click and drag from the Navigation controller to the new View and choose "Relationship - Root View Controller"
  7. Drag a "Bar Button Item" on to the Navbar which should be visible on the top of your ViewController, you can rename this Forward if you wish.
  8. Now drag on another view controller which is the one your "Forward" button will push in to view.
  9. Right Click and drag from the bar button to the 2nd View Controller, and choose "Push"

运行项目,你将获得一个带有Navbar的单一视图和你的按钮,点击你的按钮将推动另一个视图,并给你一个后退按钮返回到第一个视图控制器。如果它有帮助,我会尝试发布我的故事板的图片。

Run the project and you will get a Single view with a Navbar and your button, clicking your button will Push the other view and give you a Back Button to return to the first View Controller. I'll try and post a picture of my storyboard if it helps.

等离子

这篇关于不支持推送导航控制器 - 执行segues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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