I have a an app running on Iphone 5 and all the elements fit perfectly, I want to run the app also on Iphone 3 and Iphone 4.
I read a few articles about the Auto Sizing but I could not find any information specific for this issue.
Do I need to have a multiple Images with different sizes?
Do I need to set the elements size grammatically ?
Any help guys....
Thanks.
- You need to have a multiple Images with different sizes.
- You need to set the elements size programmatic ally in viewWillApear method.
-(void)viewWillAppear:(BOOL)animated
{
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
[splashImage setFrame:CGRectMake(0, 0, 320, 548)];
[splashImage setImage:[UIImage imageNamed:@"splash_Image_320X568@2x.jpg"]];
}
else
{
[splashImage setFrame:CGRectMake(0, 0, 320, 460)];
[splashImage setImage:[UIImage imageNamed:@"splash_Image_320X.jpg"]];
}
}
If your application is thought for iPhone 5, it will be complicated due to the smaller screen size, but here is what you have to do :
- All your images are supposed to be in two sizes, classic and @2x. The classic size will be used for iPhone 3GS.
- If you are already using autolayout you're ready, cross your finger and let's go.
- If not, you should think about using autolayout, read some tutorial about it, but simply it allows you to design a single interface for all your screen sizes.
- If you don't want to use autolayout (or if you can't), you should place all your elements directly in your code to be sure they aren't "out" the screen.