At the point of loading the nib, ask the system what type of device you are running on and then load the appropriate nib file. Use something like this:
DetailController *detailController;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
detailController = [[DetailController alloc] initWithNibName:@"DetailController" bundle:nil];
} else {
detailController = [[DetailController alloc] initWithNibName:@"DetailController-ipad" bundle:nil];
}
You may also want to do something different with your detail view controller in the different interface idioms, such as put the view controller in a UINavigationController
on the iPhone and a UISplitViewController
on the iPad.
A further option is to have a separate DetailController
implementations for iPhone and iPad. Your interface may be very similar in both interface idioms, and one DetailController would be better. Or you may have significantly different interfaces for the iPhone and iPad versions of your app, where a iPhoneDetailController
and a iPadDetailController
would make more sense. For example the smaller screen of the iPhone may necessitate the use of a UINavigationController, but the larger iPad screen can contain the entire interface on one screen.
Edit responding to a comment:
The Interface Builder portion of Xcode sets the interface idiom at creation of the .xib files, blocking conversion of a .xib from iPhone format to iPad format. Make a new interface file for the iPad .xib. You can copy and paste the elements from your iPhone .xib to your iPad .xib, then reconnect the outlets and adjust sizing and placement.