2013-11-21 64 views
1
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0xa46e6a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.' 

我一直在研究這個過去幾天,但我還沒有找到讓我的應用程序運行的答案。通用試圖顯示不同的筆尖文件

我有一個通用的應用程序,有兩個筆尖文件(一個用於手機,一個用於打擊墊),無論我改變什麼,我都會遇到這個運行時錯誤。我已經在Interface Builder中對連接進行了三重檢查。我還分別定義了手機和鍵盤的主界面。

這是我AppDelegate.m是什麼樣子:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions 
{ 
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 

ViewController *viewController; 

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 
}else { 
    viewController = [[ViewController alloc] initWithNibName:@"ViewController-iPad" bundle:nil]; 
} 

self.window.rootViewController = viewController; 
[viewController release]; 

[self.window makeKeyAndVisible]; 
return YES; 
} 

回答

1

我想建議檢查的ViewController您XIB文件。

  1. 文件所有者的自定義類是否設置爲ViewController?
  2. 並查看出口連接到文件的所有者?

然後再試一次。

+0

是的,是的。不幸的是仍然遇到了同樣的錯誤。 – galen

+0

謝謝你@Charles你的2.點。你是Rockstar。 –