xcode Push Segue 的奇怪错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15017191/
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
Strange Error with Push Segue
提问by George Friday
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] * 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)
2013-02-21 20:55:36.556 CTS Calculator[22637:c07] * 由于未捕获的异常“NSGenericException”而终止应用程序,原因:“找不到用于 segue 的导航控制器到计算器”。Push segues 只能在源控制器由 UINavigationController 的实例管理时使用。*第一掷调用堆栈:(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:终止叫做抛出异常(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?
我不确定为什么我第一次按下计算器按钮时没有发生这种情况。我有一个返回菜单的自定义转场转换,但不是从菜单到计算器。我相信我的导航控制器设置得很好。任何想法可能是什么问题?
回答by Anil Varghese
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
错误显示您没有导航控制器。并且您正在将 segue 样式设置为 push。将 segue 样式更改为 modal 并尝试一下。
是的。您可以使用push
根视图控制器应该是导航控制器。检查这些链接
将导航控制器添加到故事板
使用故事板构建导航控制器和表格视图