2011-05-27 116 views
4

我有一個非常簡單的基於窗口的應用程序,我只是把一個導航視圖控制器作爲窗口的根視圖控制器,它崩潰了。這是我的模板項目唯一改變的事情:簡單的應用程序崩潰?

@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 

回答

4

看起來你必須在一個前現有的UINavigationController IBOutlet中的連接你的筆尖文件。

從MainWindow.xib開始並檢查這種連接。

+0

感謝您的回覆。只是檢查了一切,它被連接起來了。這裏有4件事,應用程序委託,文件所有者,窗口和第一響應者。手動檢查了所有網點,重新分配。在插座窗格中也沒有感嘆號。 – sumderungHAY 2011-05-27 01:26:32

+1

嘗試從設備或模擬器中刪除應用程序。 – 2011-05-27 02:27:12

+0

沒有運氣。感謝您試圖幫助我。我上傳了這個項目:https://rapidshare.com/files/3683206909/ZebraSDKTest.zip如果你有時間,也許你可以看看它?再次感謝。 – sumderungHAY 2011-05-27 02:42:34

2

我只在模擬器上發生過這個問題,但在設備上工作正常。

我試着清理項目,重新啓動Xcode,調試,清空模擬器數據,整個工程。

最後,它通過從模擬器中卸載應用程序並重新安裝它來解決。不知道爲什麼這有效,但它解決了它!