3

Possible Duplicate:
iOS 6 apps - how to deal with iPhone 5 screen size?
Same xib for iPhone4 and iPhone5 possible?

I have been making my application and this whole time it has been with the iPhone 5 screen size. I forgot all about the iPhone 4, I even have it, dumb me... How would I go about this? Now that I have coded for the iPhone 5, how would I my code work on both screen sizes?

Here is a mockup of the kind of problem i'm having. In the second picture the slider is cut off the screen on the smaller device

4 inch screen with all interface elements 3.5 inch screen with interface cut off

Community
  • 1
  • 1
  • 1
    Have you tried to simply use the 3.5inch simulator and look what happens? ;-) – LombaX Nov 09 '12 at 20:08
  • Yes, I think some native controls like `UITableView` will autosize. – woz Nov 09 '12 at 20:09
  • @LombaX yupp haha it's not a good time at all.. many of my objects are off the screen :/ –  Nov 09 '12 at 20:09
  • 1
    Here's something similar: http://stackoverflow.com/questions/12702546/same-xib-for-iphone4-and-iphone5-possible Maybe a duplicate? – woz Nov 09 '12 at 20:11
  • 1
    I think we have a dup: http://stackoverflow.com/questions/12396545/ios-6-apps-how-to-deal-with-iphone-5-screen-size. I will flag it as such. – woz Nov 09 '12 at 20:13
  • @woz I saw that thread, I was still confused. As I don't want to worry about resizing it when switching from landscape to portrait and vice versa. It is when I scale down to the iPhone 4/4S screen size... I have been try a lot and still confused. –  Nov 09 '12 at 20:16
  • Yes, it's a hard problem. Can you post some screenshots of some specific problems? – woz Nov 09 '12 at 20:20
  • I threw together a test here to explain it, rather than showing an actual application.. [IMG]http://i.imgur.com/pExEu.jpg[/IMG] [IMG]http://i.imgur.com/pExEu.jpg[/IMG] –  Nov 09 '12 at 20:25
  • Those are both the same image. – woz Nov 09 '12 at 20:30
  • Sorry, about that. Here's the second image [IMG]http://i.imgur.com/hJsJi.jpg[/IMG] –  Nov 09 '12 at 20:31

2 Answers2

1

The best advice I can give you is to try out the autosizing/auto-alignment settings on you XIB. This is your best bet to avoid setting up separate views for each device.

In the example you gave you can use the settings in Xcode that look like this:

enter image description here

Adjust them so that your slider's origin is the bottom of the screen. Play around with the settings for each UI element until everything looks right.

woz
  • 10,888
  • 3
  • 34
  • 64
  • Thank you so much! I have messed around with those settings, and for now they have done the job. I really appreciate it! –  Nov 09 '12 at 20:49
0

What you can do strictly depends on how you defined your interface and what your UI looks like.

If you created your UI in Interface Builder/Storyboard, you might try reviewing all of your controls and views metrics settings. Two major hints in this regard:

  1. chances are that by carefully choosing autoresizing behavior you might get some improvement. For some elements you might need to fix the distance from the screen edge, for others you might need to set flexible width and height: it strongly depends on your UI.

  2. A good technique to control the proper positioning of related UI elements is to group them into a superview that you can then displace or let scale (assigning it flexible width or height) by preserving the relative position of those elements.

If you defined your interface in code, you should review the way you defined all of your positions and sizes, and instead of setting them as absolute values, you could recode them as percentages of the screen size.

I have use both techniques in my apps, both for supporting iPhone4/5 and iPhone/iPad. In any case, this is some work. It could be a lot of work, or just some work, depending on what is going bad in your app UI.

If you are looking for an automatic way to fix this, try to apply a scaling transform to your main view (say, in your app delegate):

window.rootViewController.view.transform = CGAffineTransformMakeScale(1.0, 0.84);

I am not sure if this will work at all, but in the best case I think this would more appropriately be useful to have a feeling for the fact that no automatic fix is possible.

sergio
  • 68,819
  • 11
  • 102
  • 123
  • I'm sorry if I seem a little slow when trying to grasp this... as I am a fairly new developer and I really got confused when this new screen resolution came out. Not developing for the bigger, but scaling down to the smaller to appeal to both the iPhone 4/4S market and iPhone 5 market. –  Nov 09 '12 at 20:20
  • Don't worry, take your time. You will need to try several things out. Maybe you could just give a quick shot to the `transform` approach as a start, you can never know if it will work for a specific UI. – sergio Nov 09 '12 at 20:26
  • Im afraid to say, I do not know the transform approach. I never had to deal with screen orientation and sizing. Would that be in the documentation? –  Nov 09 '12 at 20:33