我是iOS应用开发的新手,目前面临从UIButton到UIViewController的一些问题。我在Main.storyboard上面做过:
运行后,我得到以下错误
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
需要帮助解决上述错误。如果解决方案附带截图,我会很感激,因为我是新手。谢谢!
实施@technerd解决方案后,它仍然无效。以下是导航控制器菜单和动作搜索菜单
的图像答案 0 :(得分:2)
从错误日志中看,您的故事板中没有嵌入UINavigationController
作为初始控制器。
首先将UINavigationController
设置为初始控制器。
因为push
和pop
操作仅在有可用的导航堆栈时执行。
要了解导航堆栈的工作原理,请完成此link。
将Navigation设置为InitialViewController后,将第一个想要显示的视图控制器设置为该导航控制器的rootViewController。
然后你可以将push从按钮拖到secondViewController,从firstViewController推送到secondViewController。
您可以在屏幕截图中看到Push(Deprecated)
,因此您必须使用Show
关系。 Show
也执行与Push
相同的操作。
更新:
根据您的问题更新,您面临的是您无法显示其他动作搜索。按照以下步骤使其可用。
Use Trait Variations
下启用Interface Builder Document
选项。有关详细信息,请查看此thread。
答案 1 :(得分:0)
将导航控制器添加到初始视图
答案 2 :(得分:0)