【问题标题】:simple app crashing?简单的应用程序崩溃?
【发布时间】:2011-05-27 01:07:37
【问题描述】:

我有一个非常简单的基于窗口的应用程序,我只是将导航视图控制器作为窗口的根视图控制器,它正在崩溃。这是我在模板项目中唯一更改的内容:

@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

)

【问题讨论】:

    标签: iphone objective-c cocoa-touch ios crash


    【解决方案1】:

    您的一个 nib 文件中似乎与以前现有的 UINavigationController IBOutlet 建立了连接。

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

    【讨论】:

    • 感谢您的回复。刚刚检查了所有内容,它已连接。那里有 4 个东西,应用程序委托、文件所有者、窗口和第一响应者。手动检查了他们所有的网点,重新分配。出口窗格中也没有感叹号..
    • 尝试从设备或模拟器中删除应用。
    • 不走运。感谢您尝试帮助我。我在这里上传了项目:rapidshare.com/files/3683206909/ZebraSDKTest.zip如果你有时间,也许你可以看看它?再次感谢。
    • Xcode 菜单中,转到Product > Clean。完成后,构建您的项目并运行它。
    • 我刚刚下载并运行了您的应用程序,完全没有问题,所以我不确定是什么问题。代码似乎很好,xib 文件也是如此。我想这是您的模拟器或 xcode 的内部问题。我会接受@Deepak 的建议并清理它。如果这不起作用,退出 xcode 和模拟器,然后再次打开它,看看是否能解决问题
    【解决方案2】:

    我只在模拟器上遇到过这个问题,但在设备上它工作正常。

    我尝试清理项目,重新启动Xcode,调试,清空模拟器数据,全部工作。

    最终通过从模拟器中卸载应用程序并重新安装它来解决它。不知道为什么会这样,但它解决了它!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-12
      • 1970-01-01
      • 2016-07-09
      • 2015-12-31
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多