我刚刚使用两个 View 创建了一个带有 Storyboard 的计算器应用程序。我启动了我的模拟器,一开始一切正常。在第一个屏幕上,我可以使用“计算器”按钮切换到第二个屏幕,在第二个屏幕上我有一个返回主菜单的按钮。但是当我第二次从主菜单切换回计算器时,应用程序崩溃了,并出现以下错误:
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)
我不知道为什么我第一次按下计算器按钮时没有发生这种情况。我有一个返回菜单的自定义 segue 过渡,但不是从菜单到计算器。我相信我的导航 Controller 设置得很好。任何想法可能是什么问题?
最佳答案
错误显示您没有导航 Controller 。你正在设置 segue 风格来插入。将 segue 样式更改为 modal 并尝试一下。
是的。您可以使用 push
那么 Root View Controller 应该是一个导航 Controller 。
检查这些链接
Adding a Navigation Controller to a Storyboard
Use Storyboards to Build Navigation Controller and Table View
关于ios - Push Segue 的奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15017191/