我在AppDelegate遇到了问题,运行应用程序时我收到了以下错误:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<UIApplication 0x856c820> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key view.'
这是AppDelegate.h的代码
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>{
//UINavigationController *navigationController;
}
@property (strong, nonatomic) UIWindow *window;
@property (copy, nonatomic) ViewController * viewController;
@property (copy, nonatomic) UINavigationController * navigationController;
@end
这是AppDelegate.m的代码。
#import "AppDelegate.h"
#import "RootViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController *rootMenu;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
rootMenu= [[RootViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
} else {
rootMenu = [[RootViewController alloc]initWithNibName:@"ViewController_iPad" bundle:nil];
}
self.navigationController =[[UINavigationController alloc]initWithRootViewController:rootMenu];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
我该如何解决这个错误?我已经重新编写了RootViewController,抛弃了旧的,但问题仍然存在。谢谢提前。