在iPhone 5和其他设备上管理屏幕高度差异的最佳方法 [英] Best way to manage screen height differences on iPhone 5 and others

查看:57
本文介绍了在iPhone 5和其他设备上管理屏幕高度差异的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

管理iPhone 5与其他版本之间的屏幕高度差异的最佳方法是什么?

What is the best way to manage screen height differences between iPhone 5 and other versions?

如果我们使用情节提要或xib,它将相应地调整其大小.但是,如果整个视图是通过程序构建的,那么我们将如何处理此问题.

If we use the storyboard or xib it will resize it accordingly. But if the whole view is build programmatically, how we take care of this issue.

当前我要做的是获取整个屏幕的高度,并根据此高度(例如height * .7或height * .5 ..

Currently what I do is that I get the whole screen height and set the rest of the UI elements according to this height like height * .7 or height *.5 ..

但是仍然不能给我最好的体验.

But still it didn’t give me the best experience.

谢谢

推荐答案

您可以检查 [UIScreen mainScreen] .bounds.size.height (可以将其用作静态方法,也可以 #define ),然后根据屏幕高度进行屏幕设计.另一种方法是使用 view.autoresizingMask 属性调整视图.

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.

例如:-

view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

如果要针对iOS 6进行构建,则可以使用

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

这篇关于在iPhone 5和其他设备上管理屏幕高度差异的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆