Reputation: 12442
I have a universal app but this issue seems to only relate to the iPad and not the iPhone since the iPhone version loads the correct XIB.
So pretty much the issue is, it is not loading my main XIB for my app. I named the XIB's like so:
For iPhone: MyViewController.xib
Also I deleted my MainWindow.xib because in the template project for a universal app it shows no MainWindow.xib anywhere.
This is how I am trying to load the view on app launch:
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[[ocrapiViewController alloc] initWithNibName:@"MyViewController" bundle:nil] autorelease];
} else {
self.viewController = [[[ocrapiViewController alloc] initWithNibName:@"MyViewController_iPad" bundle:nil] autorelease];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
This is the crash info:
A SIGABRT on this line [self.window makeKeyAndVisible];
And this is the crash log:
2011-12-07 07:37:46.560 ocrapi[763:607] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/29F4CD7A-149E-46EA-B280-3D188PP19D17/.app> (loaded)' with name 'MyViewController_iPad''
Edit1: Here is the message:
warning: No copy of <No file name> found locally, reading from memory on remote device. This may slow down the debug session.
Also if I click on my products then do show in finder, then do show package contents, MyViewController.xib or MyViewController_iPad.xib is not there. Is it supposed to be like that?
Upvotes: 0
Views: 1171
Reputation: 535402
Make sure your nib really really really is called MyViewController_iPad.xib, with that exact capitalization.
Make sure the xib file is in your target's list of things to be copied to the app on build.
Finally, make sure you've no Main Nib setting still in your Info.plist file.
Oh, and one more thing. There is no need for this code:
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[[ocrapiViewController alloc] initWithNibName:@"MyViewController" bundle:nil] autorelease];
} else {
self.viewController = [[[ocrapiViewController alloc] initWithNibName:@"MyViewController_iPad" bundle:nil] autorelease];
}
Simply call initWithNibName:@"MyViewController"
. If your iPad nib is named MyViewController~ipad.xib (note the twiddle, note the lowercase "ipad") it will be chosen automatically when you're on an iPad.
Upvotes: 2