ios - 按下按钮时应用程序崩溃; iOS模拟
<p><p>我正在构建/学习我的第一个 Xcode 应用程序。我以前用过 C,现在正在尝试学习 Objective C 来构建 iPhone 应用程序。</p>
<p>我构建了一个简单的应用程序,当我运行 iOS 模拟器并按下一个指向 Storyboard中另一个屏幕的按钮时,应用程序崩溃了。到目前为止,我已经使用 Storyboard构建了整个应用程序。 </p>
<p>这是我的整个 main.m 文件... </p>
<pre><code>#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass());
}
}
</code></pre>
<p>这是错误...</p>
<blockquote>
<p>2014-03-02 21:22:04.422 Meal Plan Generator <strong>* 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.'
*</strong> First throw call stack: ( 0 CoreFoundation 0x00000001018a2795 <strong>exceptionPreprocess + 1651 libobjc.A.dylib<br/>
0x00000001015ee991 objc_exception_throw + 432 UIKit<br/>
0x00000001006ef051 -[UIStoryboardPushSegue
destinationContainmentContext] + 0 3 UIKit<br/>
0x0000000100252096 - + 80
4 UIKit 0x0000000100252044
- + 17 5 UIKit 0x0000000100326450 -[UIControl
_sendActionsForEvents:withEvent:] + 203 6 UIKit 0x00000001003259c0 - + 530 7<br/>
UIKit 0x0000000100286c15 -[UIWindow
_sendTouchesForEvent:] + 7018 UIKit 0x0000000100287633 - + 988 9 UIKit<br/>
0x0000000100260fa2 - + 21110UIKit<br/>
0x000000010024ed7f _UIApplicationHandleEventQueue + 954911
CoreFoundation 0x0000000101831ec1
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION</strong> + 17 12CoreFoundation 0x0000000101831792
__CFRunLoopDoSources0 + 242 13CoreFoundation 0x000000010184d61f __CFRunLoopRun + 767 14CoreFoundation<br/>
0x000000010184cf33 CFRunLoopRunSpecific + 467 15GraphicsServices<br/>
0x00000001039923a0 GSEventRunModal + 16116UIKit<br/>
0x0000000100251043 UIApplicationMain + 1010 17Meal Plan Generator<br/>
0x0000000100001193 main + 115 18libdyld.dylib<br/>
0x0000000101f1a5fd start + 1 ) libc++abi.dylib: terminating with
uncaught exception of type NSException (lldb)</p>
</blockquote></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>错误表明您正在尝试使用推送选项,但您的 ViewController 没有导航 Controller 。在您的 Storyboard中单击您尝试推送的第一个 View ,然后从编辑器部分的顶部菜单中选择嵌入,然后选择导航 Controller 。该错误将消失。确保您的标识符也在 Storyboard中为 segue 设置。或者选择segue并将其更改为modal,然后尝试,应用程序将编译。</p></p>
<p style="font-size: 20px;">关于ios - 按下按钮时应用程序崩溃; iOS模拟,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/22137504/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/22137504/
</a>
</p>
页:
[1]