0

I have an app developed and tested on my iPhone 5, but now I would like to make it work on older iphones as 4 and 4s. The functionalities work in the same way, but there are some buttons which do not appear because of the screen resolution.

Is there any way I can make the same .xib to work on different screen resolutions?

bneely
  • 9,083
  • 4
  • 38
  • 46
  • It all depends on what functionality your app is doing and if that functionality is compatible with the 4 or 4s. – logixologist Nov 25 '13 at 22:32
  • 1
    See http://stackoverflow.com/questions/12396545/ios-6-apps-how-to-deal-with-iphone-5-screen-size?rq=1. You are just doing this in reverse but the answer is the same. – rmaddy Nov 25 '13 at 22:33
  • I have read those answers, but all them refer to the launch image and how other images should be loaded depending on the screen resolution we have. But my question is also in positioning the various elements we have on screen. Is there any way to do this automatically? – Daniel Belém Duarte Nov 25 '13 at 22:41

2 Answers2

3

a) You can always design your interfaces (.xib) with anchor or elastic coordinates, so if the screen is bigger/smaller, the coordinates are relative to one of the edges of the screen.

b) You can WRAP the entire screen in a UIScrollView and let the user SCROLL to access all buttons.

These are the easiest. a) will give you more headaches. I would go for b) because it's more time efficient.

For b) I also recommend that you TRY the interface in a smaller screen and check that the hidden content is PARTIALLY VISIBLE, so users have a HINT that there's "something down there".

EDIT

This is an example for initializing a viewController with different xib files.

- (id)init
{
     int model = ... //some model inspection method;
     switch(model) {
          case iphone3g:
              return [self initWithNibName:@"iphone3g.xib" bundle:nil];
          case iphone4:
          case iphone4s:
              return [self initWithNibName:@"iphone4x.xib" bundle:nil];

... //etc
Felipe Baytelman
  • 544
  • 3
  • 12
  • 1
    Thanks for your response. I can create multiple .xib files, but how can I load diferent .xib files depending on the iPhone the app is running? Thanks Best Regards – Daniel Belém Duarte Dec 18 '13 at 14:36
1

I would suggest Apple's WWDC videos on auto layout, those will help with using the same XIB. It really depends on your interface and what you're looking to do, there's no one right answer.

You could also create two XIBs, one for 480 height and another for 568, then write in code a bit to ask the device what size it is, and load the appropriate XIB. This can be useful if auto layout just seems to be a big pain with what you're implementing.

CBanga
  • 131
  • 2
  • 4