OGeek|极客世界-中国程序员成长平台

标题: ios - 按下按钮时应用程序崩溃; iOS模拟 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 19:45
标题: ios - 按下按钮时应用程序崩溃; iOS模拟

我正在构建/学习我的第一个 Xcode 应用程序。我以前用过 C,现在正在尝试学习 Objective C 来构建 iPhone 应用程序。

我构建了一个简单的应用程序,当我运行 iOS 模拟器并按下一个指向 Storyboard中另一个屏幕的按钮时,应用程序崩溃了。到目前为止,我已经使用 Storyboard构建了整个应用程序。

这是我的整个 main.m 文件...

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char * argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

这是错误...

2014-03-02 21:22:04.422 Meal Plan Generator[4777:70b] * Terminating app due to uncaught exception 'NSGenericException', reason: 'ush segues can only be used when the source controller is managed by an instance of UINavigationController.' * First throw call stack: ( 0 CoreFoundation 0x00000001018a2795 exceptionPreprocess + 165 1 libobjc.A.dylib
0x00000001015ee991 objc_exception_throw + 43 2 UIKit
0x00000001006ef051 -[UIStoryboardPushSegue destinationContainmentContext] + 0 3 UIKit
0x0000000100252096 -[UIApplication sendAction:to:from:forEvent:] + 80 4 UIKit 0x0000000100252044 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17 5 UIKit 0x0000000100326450 -[UIControl _sendActionsForEvents:withEvent:] + 203 6 UIKit 0x00000001003259c0 -[UIControl touchesEnded:withEvent:] + 530 7
UIKit 0x0000000100286c15 -[UIWindow _sendTouchesForEvent:] + 701 8 UIKit 0x0000000100287633 -[UIWindow sendEvent:] + 988 9 UIKit
0x0000000100260fa2 -[UIApplication sendEvent:] + 211 10 UIKit
0x000000010024ed7f _UIApplicationHandleEventQueue + 9549 11 CoreFoundation 0x0000000101831ec1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 17 12 CoreFoundation 0x0000000101831792 __CFRunLoopDoSources0 + 242 13 CoreFoundation 0x000000010184d61f __CFRunLoopRun + 767 14 CoreFoundation
0x000000010184cf33 CFRunLoopRunSpecific + 467 15 GraphicsServices
0x00000001039923a0 GSEventRunModal + 161 16 UIKit
0x0000000100251043 UIApplicationMain + 1010 17 Meal Plan Generator
0x0000000100001193 main + 115 18 libdyld.dylib
0x0000000101f1a5fd start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)



Best Answer-推荐答案


错误表明您正在尝试使用推送选项,但您的 View Controller 没有导航 Controller 。在您的 Storyboard中单击您尝试推送的第一个 View ,然后从编辑器部分的顶部菜单中选择嵌入,然后选择导航 Controller 。该错误将消失。确保您的标识符也在 Storyboard中为 segue 设置。或者选择segue并将其更改为modal,然后尝试,应用程序将编译。

关于ios - 按下按钮时应用程序崩溃; iOS模拟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22137504/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4