Trying to make my app work with both iPhone 5 and iPhone 4/4s. I tried the “AutoLayout” but does not seem to work for my app also read that it is not supported in iOS 5. AutoLayout specifically fails on a view controller that has an UIScrollview and a UIPicker that is re-sized in code. Having two Storyboards one for 4 inch and one for 3.5 inch seems the way to go.
The two Storyboard aproch seem to be the solution for me. So this leaves me with two questions;
-
Where should the code to detect then if it is a 4/4s/5 go? I would assume in the appDelegate.m in the didFinishLaunchingWithOptions method
-
How do I change the “Main Storyboard”?
This is a great question.
What you need to do is,
Select your current 4/4s storyboard, go to File, duplicate, then give it an iPhone 5 specific name.
Make sure that Target and your app name is checked.
Next you have to select the scenes in your storyboard and in the Attributes Inspector change the size to Retina 4 Full Screen.
This allows you to rearrange everything for this display.
Finally in application didFinishLaunchingWithOptions paste the following code with the storyboard name you gave for your 4 inch storyboard.
If anyone don’t get how to do step 1, do as below.
Go to Project directory and copy paste the
MainStoryboard.storyboardand rename new storyboard to sayMainStoryboard5.storyboard.Add this new storyboard
MainStoryboard5.storyboardin project (in Xcode) by right clicking Project and clickingAdd Files to ....Now we have two storyboards in xcode.
Tip
You may have to use ‘Product > Clean’ for this to work after you have done all the above.