1

I never used Interface Builder ever in my app, and don't think it is something good to do.

My app was already designed for iPad/iPad2 layout, without ever considering making it work on iPhone4/iPhone5/iPAD-mini. Now I want my app to work on all of them.

I think it would be extremely ugly to have 4+ layout the universal app, like this:

if(ipad or ipad2) 
 view.frame = CGRectMake(0,0,100,100);
else if(ipad-mini)
  view.frame = CGRectMake(0,0,100,100);
else if(iphone4)
  view.frame = CGRectMake(0,0,100,100);
else if(iphone5)
  view.frame = CGRectMake(0,0,100,100);
else if(iphone6)
  view.frame = CGRectMake(0,0,100,100);
else if(iphone7)
  view.frame = CGRectMake(0,0,100,100);

There should be only 2 layout ideally, but I don't know how to implement this way. Those fixed coordinates would not stretch on different screen sizes

if(ipad or ipad2 or ipad-mini) 
  view.frame = CGRectMake(0,0,100,100);
else if(iphone4 or iphone5 or iphone6 or iphone7)
  view.frame = CGRectMake(0,0,100,100);

How do I do a universal app in the best way?

Nuby Joe
  • 57
  • 1
  • 5
  • The iPad mini layout is identical to the other iPads. You only need to deal with the two different iPhone/iPod touch screen sizes (as well as retina/non-retina). – rmaddy Jun 18 '13 at 23:53

2 Answers2

0

when you started building this app you should have done soemthing like this:

 view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;

and you change above options according to your needs.

and yes you would need different for ipad, iphone

Jatin
  • 1,668
  • 2
  • 16
  • 23
0

First of all, your layout for iPhone will almost certainly be drastically different from iPad. For the iPads, all the different types have the same aspect ratio, so all you need to worry about is having the @2x images for the iPad with retina.

For the iPhone, however, you have the iPhone 4/4s VS the iPhone 5. Also, you have a lot less screen space, so you will need to find ways to present the same information in a smaller space. This can be done using scrollviews, tableViews, and having one part of the information in one viewController that you can switch to from another viewController.

Finally, I would highly recommend interface builder for most cases. It takes care of iPhone vs iPhone 5, and portrait vs landscape for you. It will even automatically animate the transition when rotating the phone. Sometimes, however, when you need to do custom drawing or our layout is really hard to get with interface builder, it is better to do it programmatically. In that case, a good way to check which device would be by checking the size of [[UIScreen mainScreen] applicationFrame]. Check that with the values of 1024x768 for an iPad, 320x480 for iPhone, or 320x568 for iPhone 5.

However, you really should use interface builder (for most cases). Why exactly do you want to avoid it?

WolfLink
  • 3,308
  • 2
  • 26
  • 44