3

I'm working on the new app with Xcode 4.5 and going to use deployment target to iOS 4.3. App should be support iphone 5 & iPhone 4. I googled for design the iPhone 5 & iPhone 4 and saw following url.

iOS 6 apps - how to deal with iPhone 5 screen size?

We can use autoresizingmask for iPhone 5 & iPhone 4 design. I did some screen design for iPhone 5 & iPhone 4. But, i have a doubt. autoresizingmask is to be used for iPhone5 also? I have used iPhone 4 only. Need to verify the following code. Pls help for me.

if ([[UIScreen mainScreen] bounds].size.height < 568) {
    topView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | 
                               UIViewAutoresizingFlexibleBottomMargin | 
                               UIViewAutoresizingFlexibleLeftMargin | 
                               UIViewAutoresizingFlexibleRightMargin |  
                               UIViewAutoresizingFlexibleWidth | 
                               UIViewAutoresizingFlexibleHeight ;
}

The above code is right? or autoresizing should be use iPhone 5 also?

Community
  • 1
  • 1

2 Answers2

1

If you want the view top be fixed to all four sides and resize its width and height then you should only use:

UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight

Note that the autoresizing in code says that the margin to the sides should be flexible while the inspector says they should be fixed. Leaving out a flexible margin means that the margin is fixed.

David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
  • Ronnqvist Hi, i dont have problem for autoresizingmask. My question is, autoresizing mask is to be used for iPhone 5 when design the app for iphone 5 & iphone 4 support? – user1756388 Oct 25 '12 at 05:50
  • It _can_ be used. Since iOS 6 (the earliest version the iPhone 5 runs) you can use the new Autolayout to configure the position and size of your views in relation to each other but you can still use autoresizing marks if you need compatibility with iOS5. – David Rönnqvist Oct 25 '12 at 07:58
1

iPhone 5 (or any device running iOS 6) will translate these masks into auto layout constraints for you, and it likely will until iOS 5.x is no longer supported.

borrrden
  • 33,256
  • 8
  • 74
  • 109