0

I'm building a universal app with support to iOS 5.1.X and 6.X. But I have a question for you guys. On iOS 5.1.X autolayout is not supported and I thought for a solution to have 3 nibs 1)ipad 2)iphone retina and not retina 3)iphone 5. One of the reason I have thought to use 3 nibs is because is load it with graphics and animations but I'm no to sure it will be the best solution. I'll like to know your opinions to this approach or suggestions for a different solution.

Juan
  • 627
  • 2
  • 9
  • 27

3 Answers3

0

Do not let AutoLayout force you into a corner like this. You have to remember: the layout in the XIB is never absolute. You have the option of writing layout code in -viewDidLoad, (or, even better, -layoutSubviews) and with some creative math, you could even cut your app down to one universal XIB with the proper layout code in your view controller.

Your app should never have to have more than 2 XIBs for a view controller if it is in fact universal (and the iPad version and Pod-like devices versions are different enough to warrant a separate layout or design).

CodaFi
  • 43,043
  • 8
  • 107
  • 153
0

you can do as following

First determine wether device is iphone or ipad

int iphone =0;

 if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
     iphone = 0;
}
else
{
     iphone = 1;
}


NSString* nibName;

if(iphone == 0)
{
     nibName = @"SettingsiPadView";
}
else
{
    nibName = @"SettingsiPadView";
}

Settings* setObj = [[Settings alloc]initWithNibName:nibName bundle:nil];
[self.navigationController pushViewController:setObj animated:YES];
iDhaval
  • 7,824
  • 2
  • 21
  • 30
0

Loading three nibs is not a problem. Imagine you are building an universal app. Now if you try to use the same nib file fir both ipad and iphone then its a blunder. Your ui all getts messed up. But for retina and non retina you can go for 1x and 2x images so that you can use the same nib file. But if you really want to use 3 nib files here I would say use 1x and 2x images

Prajwal Udupa
  • 860
  • 5
  • 28