You can check the height of the screen, and programmatically choose which xib you want to use:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
MyFirstViewController *vc1 = nil;
MySecondViewController *vc2 = nil;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
if(screenSize.height == 568) {
vc1 = [[MyFirstViewController alloc] initWithNibName:@"LargeFirstViewController" bundle:nil];
vc2 = [[MySecondViewController alloc] initWithNibName:@"LargeSecondViewController" bundle:nil];
}
if(screenSize.height == 480) {
vc1 = [[MyFirstViewController alloc] initWithNibName:@"SmallFirstViewController" bundle:nil];
vc2 = [[MySecondViewController alloc] initWithNibName:@"SmallSecondViewController" bundle:nil];
}
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// ... Add iPad code here if relevant.
}
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[vc1, vc2];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
To change the tab bar icon image programmatically edit the following in your view controller (replace "YOUR-IMAGE" with the actual name... do not put the extension (such as .png)):
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.tabBarItem.image = [UIImage imageNamed:@"YOUR-IMAGE"];
}
return self;
}
When you create a new xib file, don't forget to select the "File Owner" (under "Placeholders") and set the "Custom Class" to the actual view controller class in the Attributes Inspector. Also, while the "File Owner" is selected, go to the "Connections Inspector" and drag the "view" outlet to the top level view of your xib.