问题
My iphone app runs on iphone simulator and devices but not on ipad simulator. It doesnt showing any errors but the application is not launching just blank black screen only displays.
While running in ipad simulator 5 it showing following error "applications are expected to have a root view controller at the end of application launch"
My application didFinishLaunchingWithOptions code is as below :
rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
[self.rootViewController.view setFrame:CGRectMake(0, 20, 320, 460)];
[self.window addSubview:self.rootViewController.view];
[self.window makeKeyAndVisible];
return YES;
And my main.m code is as below :
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
What is the wrong with this???
回答1:
Go on the App Target info and set "Target device Family":"iPhone" then it works fine both on iphone and ipad simulator and device both.
回答2:
What if you change this:
rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
to this:
self.rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
回答3:
Check....Navigation Controller delegate must have been connected (delegate > AppDelegate) in IB.
来源:https://stackoverflow.com/questions/8060422/iphone-app-not-working-ipad-simulator