Best way to manage screen height differences on iPhone 5 and others

﹥>﹥吖頭↗ 提交于 2019-12-06 12:06:58

You can check for [UIScreen mainScreen].bounds.size.height(may be, use it as a static method or do a #define) and do the screen design based on the screen height. Another way is to use the view.autoresizingMask property to adjust the views.

for eg:-

view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

If you are building for iOS 6, you can use Auto layout features.

In your viewDidLoad just check for screen size Like this...

- (void)viewDidLoad
{
   [super viewDidLoad];
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
   if (screenBounds.size.height == 568)
   {
       //iPhone 5
   }
   else
   {
       // iPhone 4
   }

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