我有一个项目,我一直在努力。这是一个iPhone专用项目,但最近发现我也需要将它提供给iPad。理论上,我应该可以在iPhone/iPad代码之间切换一些if语句,但我遇到了一个小问题。在我最初的看法,我得到了臭名昭著的错误:在iPad上运行应用程序而不是iPhone在xcode 4中时出现错误
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x8a2dcf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loginButton.'
loginButton指向一个UIButton,在我Login_iPad.xib一切都正确连接。
我敢肯定我错过了一些小东西,但任何帮助将非常感激。
谢谢!
下面是我的一些代码的AppDelegate - didFinishLaunchingWithOption:
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
UIViewController *rootView = [[Login alloc] initWithNibName:@"Login" bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:rootView];
} else {
UIViewController *rootView = [[Login alloc] initWithNibName:@"Login_iPad" bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:rootView];
}
更新:如果我删除所有的网点(包括视图出口),我,当然,出现此错误:
loaded the "Login_iPad" nib but the view outlet was not set
但是,如果我添加甚至只是出口的观点,我得到这个:
this class is not key value coding-compliant for the key view
对我来说没有意义。我将XIB的类设置为与iPhone XIB相同的类。但是,我知道我忽略了一些东西。
作为iPad应用程序运行时,我似乎无法链接任何东西。甚至没有观点......或者它抛出了那个错误。
听起来像是在你的iPad笔尖的出口无法正确链接... – diatrevolo 2012-01-09 17:31:53
有一些问题在你的xib中,如果在那里有任何警告,你检查了所有的属性吗? – rishi 2012-01-09 17:38:00