How do i make an app running on iphone 5 fit the screen of iphone 4 and 3

吃可爱长大的小学妹 提交于 2019-12-08 07:08:39

问题


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.


回答1:


  • 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"]];
    }
}



回答2:


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.


来源:https://stackoverflow.com/questions/18122401/how-do-i-make-an-app-running-on-iphone-5-fit-the-screen-of-iphone-4-and-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!