Reputation: 53
I am a newer in ios app develop. Now I met a problem for my app submit. I must support the 4-inch display on iPhone 5 because my app is based on iPhone 4. I known I can either to redesign my view frame to match the 4-inch or to multiply a number like 1.187 to the frame.origin.y to support the 4-inch. But how can I do this in the second way. my code is like this
if([[UIScreen mainScreen] bounds].size.height == 568){ //to judge if it is 4-inch screen
self.viewController = [[[IPGWViewController alloc] initWithNibName:@"myapp" bundle:nil] autorelease]; //how can I do this here to multiply the number 1.187 to the frame.origin.y
}
else{
self.viewController = [[[IPGWViewController alloc] initWithNibName:@"myapp" bundle:nil] autorelease];
}
thank you very much!
Upvotes: 0
Views: 1403
Reputation: 3853
A view controller will fill up the space it's given, so you don't need to manually adjust for the size of 3.5/4-inch screens.
As others have mentioned, though, you should be using autolayout to ensure that your UI elements are correctly positioned for all screen sizes. There is a session video from WWDC 2012 that covers the basics of autolayout, as well as lots of useful resources online (see here and here) that should help you get started.
Upvotes: 0
Reputation: 13632
Your first approach should be to use AutoLayout see the checkbox in the identity inspector of your XIB or Storyboard of the viewcontroller
An alternate approach is for you to design two different XIB one for each of your resolutions. I do not think your approach of multiplying is the way to go.
Upvotes: 0
Reputation: 4091
You need to add launch image "[email protected]"
change your xib name as "YourViewController~iphone460h.xib"
In xib, You need to set "Autosizing" left, right, up and down arrow based on your views.
Upvotes: 0
Reputation: 1223
Xcode 4.5+ does support 4inch screen automatically (you may have to add 4inch splash screen for that). It will scratch your view (you may test it on simulator). If you are building your views in interface builder you may set which subviews should stick to which side and how they can be streatchable. Also there are plenty of tutorials like this
Upvotes: 2