The new iPad Mini has the same resolution as the iPad 2, so you don’t need to worry about the Mini!
So now when loading your XIBs files you need to load three different XIBs (if your app is universal) or 2 XIBs if you’re only targeting iPhone and iPod Touch.
The code to load your XIBs is quite simple
// If Iphone/iPod Touch if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { // If iPhone 5 or new iPod Touch if([UIScreen mainScreen].bounds.size.height == 568){ UIViewController *myViewController = [[UIViewController alloc] initWithNibName:@"ViewControllerExt" bundle:nil]; ... } else{ // Regular iPhone UIViewController *myViewController = [[UIViewController alloc] initWithNibName:@"ViewController" bundle:nil]; ... } // If iPad } else { UIViewController *myViewController = [[UIViewController alloc] initWithNibName:@"ViewControllerPad" bundle:nil]; ... }
What this code actually do is:
- Check to see if the device is an iPhone/iPod or if it’s an iPad using the [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone
- Check what is the maximum device height, if it’s 568, then it’s the new iPhone 5 or iPod Touch, if not, then it’s the regular iPhone.
And that’s it. Inside the IF-ELSE statements, you load your UIViewController and do any code necessary.
Do you have any questions, comments, compliments? hit the comments below.
Thanks
.gm.