I am trying to build an universal application with Xcode 4. However, it seems a little different from past versions.
My project utilizes the View Based Application template. My issue is that I added a UIViewController subclass which has one nib file for iPad. How do I create another nib file with the same class targeted instead for iPhone? Also, how do I ensure that the proper nib file is loaded for the proper platform?
EDITED :
here is my code :
- (IBAction)BookView {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
BookViewController *viewController = [[BookViewController alloc] initWithNibName:@"BookViewController" bundle:nil];
[self presentModalViewController:viewController animated:YES];
} else {
BookViewController *viewController = [[BookViewController alloc] initWithNibName:@"BookViewController_iPad" bundle:nil];
[self presentModalViewController:viewController animated:YES];
}
}
Step 1: Create for iPhone:
This step will create .m .h and .xib files with same name, for example: CustomView
Step 2: Create new XIB for iPad:
device family iPad
In your code use something like this:
Good luck!