0

I'm having a problem with the layout (spacing) of my buttons when I switch between the iPhone 5 & 4 screen size.

On the 5 it looks just the way I want it to

However, on the 4 it bunches up. Does anyone know how I can fix this? I have been messing with the settings in the view and I can not figure out how to solve it. !

Edit: Sorry, I am not using any code. I am simply using interface builder to drag and drop them where I would like them to be. I am fairly new to using xcode and app development all together so I am not sure what the best route to go with this would be.

I have autolayout enabled.

user1777808
  • 39
  • 1
  • 9
  • Are you using constraints or struts and springs? – Bill Jan 03 '13 at 04:25
  • More details, and/or post your code please. I'm sure no one can help you from the information you've currently provided. – jhilgert00 Jan 03 '13 at 04:25
  • 1
    If you're using Autolayout (it's much easier than Springs & Struts), then see this example that horizontally distributes buttons: http://stackoverflow.com/questions/13680303/ios-auto-layout-equal-spaces-to-fit-superviews-width/13904763#13904763 – John Sauer Jan 03 '13 at 04:26
  • I've made an edit to better explain my issue. – user1777808 Jan 03 '13 at 04:46

2 Answers2

1

You have to use constraints for auto layout. You can refer this link to learn about constraints Constraints

Prince Kumar Sharma
  • 12,574
  • 4
  • 58
  • 89
  • It'd help if I could post pictures but I solved my problem using the Editor>Pin>Top Space To SuperView option to get everything to space out correctly. – user1777808 Jan 03 '13 at 05:04
0

You can use auto layout in Xib or if doing manually do this

float height = [UIScreen mainScreen].bounds.size.height;
if (height==568) {
    //give frames according to iPhone 5
}
else
{
    //give frames according to iPhone 4
}
Durgaprasad
  • 1,910
  • 2
  • 25
  • 44