2011-05-24 61 views
1

我的應用程序最近開始崩潰我需要一些幫助來弄清楚爲什麼。initWithNibName崩潰

在應用程序委託創建導航控制器

UINavigationController *localNavigationController; 
tabBarController = [[UITabBarController alloc] init]; 
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:3]; 

然後加載到3點的控制器(1示出)

SecondViewController *secondViewController; 
secondViewController = [[SecondViewController alloc] initWithTabBar]; 
localNavigationController = [[UINavigationController alloc] 

[initWithRootViewController:secondViewController]; 

[localControllersArray addObject:localNavigationController]; 
[localNavigationController release]; 
[secondViewController release]; 

一個視圖的有一個按鈕,調用按壓的動作新視圖

Ref *third = [[Ref alloc] initWithNibName:@"Fourthview" bundle:nil]; 

迄今爲止這麼好。我已經更新了,現在我想用舊的廈門國際銀行,但應用程序一旦崩潰,是因爲它推

Sup *third = [[Sup alloc] initWithNibName:@"Fifthview" bundle:nil]; 

如果我去IB和斷開所有出口的UILabel它將工作。但連接例如PNAME會崩潰

這裏的錯誤

「[setValue方法:forUndefinedKey:]:此類不是密鑰值編碼兼容的關鍵PNAME」

感謝

回答

2

Sup,正被用於加載Fifthview XIB,必須具有一個屬性或命名pName伊娃。這可能是由於XIB中的IBOutlet將pName屬性連接到文件的所有者。

XIB加載過程正在嘗試使用KVC連接XIB中定義的所有IBOutlet,實際上這意味着它調用-[setValue:forKey:],其中密鑰等於@"pName"。如果您已在Sup中聲明瞭pName屬性,請確保您在Sup.m的實施中還有@synthesize pName;的某處。

+0

你是第一個,所以你明白了。但是這是一個錯字。剛花了另一個半小時追逐我自己的尾巴:-) XIB文件名是不正確的。 – user643097 2011-05-24 01:13:39