ios - 按下按钮时应用程序崩溃; iOS模拟

标签 ios crash ios-simulator

我正在构建/学习我的第一个 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: 'Push 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)

最佳答案

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

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

相关文章:

ios - MPMoviePlayerController 模拟器崩溃

iphone - CorePlot : how to run on device?(在模拟器上工作正常)

python - 当我开始打字时 PyCharm 崩溃

android - Play 管理中心崩溃集群显示新的应用崩溃报告

ios - React Native FlatList 消耗所有触摸(ToucableWithoutFeedback onPress 未调用)

ios - NSURLSession 下载任务在成功后失败

Ios确实收到内存警告和应用程序崩溃

ios - 在 Xcode 中停止应用程序时自动关闭 iOS 模拟器

ios - 使用 NSURLSessionDownloadTask 设置并发下载数

ios - 如何根据区域设置仅显示日期的日期和月份?