iphone - 简单的应用程序崩溃?

标签 iphone objective-c cocoa-touch ios crash

我有一个非常简单的基于窗口的应用程序,我只是将导航 View Controller 作为窗口的 Root View Controller ,它崩溃了。这是我在模板项目中唯一更改的内容:

@interface AppDelegate : NSObject <UIApplicationDelegate> {
    UINavigationController *navigationController;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    navigationController = [[UINavigationController alloc] init];


    [[self window] setRootViewController:navigationController];
    [self.window makeKeyAndVisible];
    return YES;
}

它崩溃说:

2011-05-26 20:18:57.194 ZebraSDKTest[5560:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UICustomObject 0x8b3d760> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key navigationController.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00dbf5a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f13313 objc_exception_throw + 44
    2   CoreFoundation                      0x00dbf4e1 -[NSException raise] + 17
    3   Foundation                          0x00791677 _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x007915e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x0020d30c -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x00d358cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x0020bd23 -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x0020dab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x0001317a -[UIApplication _loadMainNibFile] + 172
    10  UIKit                               0x00013cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
    11  UIKit                               0x0001e617 -[UIApplication handleEvent:withNewEvent:] + 1533
    12  UIKit                           

0x00016abf -[UIApplication sendEvent:] + 71
13  UIKit                               0x0001bf2e _UIApplicationHandleEvent + 7576
14  GraphicsServices                    0x00ff8992 PurpleEventCallback + 1550
15  CoreFoundation                      0x00da0944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16  CoreFoundation                      0x00d00cf7 __CFRunLoopDoSource1 + 215
17  CoreFoundation                      0x00cfdf83 __CFRunLoopRun + 979
18  CoreFoundation                      0x00cfd840 CFRunLoopRunSpecific + 208
19  CoreFoundation                      0x00cfd761 CFRunLoopRunInMode + 97
20  UIKit                               0x000137d2 -[UIApplication _run] + 623
21  UIKit                               0x0001fc93 UIApplicationMain + 1160
22  ZebraSDKTest                        0x00002549 main + 121
23  ZebraSDKTest                        0x000024c5 start + 53

)

最佳答案

看起来您在您的一个 nib 文件中连接到以前存在的 UINavigationController IBOutlet。

从 MainWindow.xib 开始并检查这样的连接。

关于iphone - 简单的应用程序崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6146775/

相关文章:

iphone - 如何使用 AFNetworking 2.0 下载图像?

iphone - PLCrashReporter 不工作

iphone - 从 C++ 验证 iphone 收据

ios - xcode 7 和 cloudkit 的非常奇怪的问题

ios - MPMoviePlayerController 无法打开

iphone - Xcode 4.x - 使其指向有问题的崩溃行

iphone - Tab 激活时刷新 View

iphone - 如何以编程方式设置 "Hides bottom bar on push"?

iphone - 在 Objective C 中运行 AJAX 代码

objective-c - 如何在部署目标 < 4.0 的项目中仅引用 iOS 4.0 枚举?