What i think its better that you provide two seperate nib files for 3.5 and 4 inch display. Yes I know that this will increase your efforts but yes the code will be more managable in future. You just need to provide separate nibs.
You can make use of the following method to load nib dynamically each time for required dimension.
-(void)pushViewController:(UIViewController*)viewController withNib:(NSString*)nibName
{
if(nibName){
nibName=[self getNibNameForNib:nibName];
viewController=[viewController initWithNibName:nibName bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];
}
}
-(NSString*)getNibNameForNib:(NSString *)nibName
{
NSString *newNibName=nil;
if([self isIphone5Retina4InchDisplay]){
newNibName=[nibName stringByAppendingString:@"-568h"];
}
if(newNibName && [[NSBundle mainBundle] pathForResource:newNibName ofType:@"nib"] != nil)
{
//if iphone 5 and nib is also present for that resolution.
nibName=newNibName;
}
return nibName;
}
/**
Method to get if device is 4 inch iphone 5 retina device or not.
*/
-(BOOL)isIphone5Retina4InchDisplay
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for 4-inch screen
return YES;
} else {
// code for 3.5-inch screen
return NO;
}
}
JUST NAME THE RETINA 4 INCH NIB NAME AS LoginViewController-568h.xib i.e. add -568h suffix. Use this pushViewController method each time to push a new view controller. You can write this method in your Base view controller.