In my application, I do it like this. I create separate .h, .m and XIB files for iPad views, and then in AppDelegate I just make an if condition, which decides which view controller it will show.
Btw. I do not use these suffixes on XIB, I call them what I want.
My AppDelegate.h file (part of it)
@class FirstViewController; @class FirstIpadViewController; ....... ....... @property (nonatomic, retain) IBOutlet FirstViewController *viewController; @property (nonatomic, retain) IBOutlet FirstIpadViewController *ipadViewController;
My AppDelegate.m file (part of it)
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; } else { self.window.rootViewController = self.ipadViewController; [self.window makeKeyAndVisible]; }
That must do it. Just change the class and property in the .h file to your view controller, and you should be good to go :)
EDIT
I just found out how to do this. And the correct naming conventions are _iPhone and iPad. This is basically the same as above, only the change is that it will have the same .h and .m files, but different XIBs.
In the file AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; } else { self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; } self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; }
source share