Ios 我得到的应用程序预计有一个根视图控制器在应用程序启动错误结束
所以我读了类似的帖子,我想我已经拥有了我所需要的一切 在my AppDelegate.m中,函数应用程序:didFinishLaunchingWithOption如下所示:Ios 我得到的应用程序预计有一个根视图控制器在应用程序启动错误结束,ios,xcode,ios5,Ios,Xcode,Ios5,所以我读了类似的帖子,我想我已经拥有了我所需要的一切 在my AppDelegate.m中,函数应用程序:didFinishLaunchingWithOption如下所示: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initW
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[[ViewController_iPhone alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
} else {
self.viewController = [[[ViewController_iPad alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
我的appdelegate.h如下所示:
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end
请帮助,该应用程序只是加载了一个黑屏,我不知道问题出在哪里。确保您已在目标设置的“信息”选项卡中设置了iPhone和iPad的主nib文件基名称 因此,我转到了我的目标中的info选项卡,添加了两个用于主nib文件名的键,我假设您指的是ViewController_iPhone.xib(不带.xib)和类似的iPad。但现在我有一个错误:由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[setValue:forUndefinedKey:]:此类不符合key landscapeView的键值编码。”landscapeView也是在ViewController:iAction UIView*landscapeView中定义的UIView;Landscape视图链接到景观,这是我的ViewController_iPhone.xib文件中的一个视图。
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}