Push Segue 的奇怪错误 [英] Strange Error with Push Segue

查看:28
本文介绍了Push Segue 的奇怪错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用两个视图创建了一个带有故事板的计算器应用程序.我启动了我的模拟器,一开始一切正常.在第一个屏幕上,我可以使用计算器"按钮切换到第二个屏幕,在第二个屏幕上,我有一个按钮可以返回主菜单.但是当我第二次从主菜单切换回计算器时,应用程序崩溃,并出现以下错误:

I just created a calculator app with storyboards using two views. I started my simulator, and everything worked fine at first. On the first screen, I was able to use the "Calculator" button to switch to the second screen, and on the second screen I had a button to go back to the main menu. But when I switched from the main menu back to the calculator a second time, the app crashed, and the following error occurred:

2013-02-21 20:55:36.556 CTS Calculator[22637:c07] * 终止应用由于未捕获的异常NSGenericException",原因:不能为 segue 'To Calculator' 找到一个导航控制器.推segues只能在源控制器由实例管理时使用UINavigationController 的.* 第一次抛出调用堆栈:(0x15a9012 0x12b6e7e 0x650f31 0x642b99 0x642c14 0x12ca705 0x1fe2c0 0x1fe258 0x2bf021 0f20bf60x22dcef 0x22df02 0x20bd4a 0x1fd698 0x260bdf9 0x260bad0 0x151ebf50x151e962 0x154fbb6 0x154ef44 0x154ee1b 0x260a7e3 0x260a668 0x1faffc0x1ecd 0x1df5) libc++abi.dylib: 终止调用抛出异常(lldb)

2013-02-21 20:55:36.556 CTS Calculator[22637:c07] * Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'To Calculator'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.' * First throw call stack: (0x15a9012 0x12b6e7e 0x650f31 0x642b99 0x642c14 0x12ca705 0x1fe2c0 0x1fe258 0x2bf021 0x2bf57f 0x2be6e8 0x22dcef 0x22df02 0x20bd4a 0x1fd698 0x260bdf9 0x260bad0 0x151ebf5 0x151e962 0x154fbb6 0x154ef44 0x154ee1b 0x260a7e3 0x260a668 0x1faffc 0x1ecd 0x1df5) libc++abi.dylib: terminate called throwing an exception (lldb)

我不知道为什么我第一次按下计算器按钮时没有发生这种情况.我有一个返回菜单的自定义转场转换,但不是从菜单到计算器.我相信我的导航控制器设置得很好.任何想法可能是什么问题?

I am not sure why this did not happen the first time I pushed the calculator button. I have a custom segue transition going back to the menu, but not from the menu to the calculator. My navigation controller is set up fine, I believe. Any ideas what the problem might be?

推荐答案

错误显示您没有导航控制器.并且您正在将 segue 样式设置为 push.将 segue 样式更改为 modal 并尝试一下.
是的.您可以使用 push 然后根视图控制器应该是导航控制器.检查这些链接
将导航控制器添加到故事板
使用 Storyboards 构建导航控制器和表格视图

Error shows you dont have a navigation controller. and you are setting segue style to push. Change the segue style to modal and give a try.
Yes. You can use push then the root view controller should be a navigation controller. Check these links
Adding a Navigation Controller to a Storyboard
Use Storyboards to Build Navigation Controller and Table View

这篇关于Push Segue 的奇怪错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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