Xcode iPhone 4/5 屏幕尺寸 两者
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13386957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode iPhone 4/5 Screen Size Both
提问by Steelzeh
I am making an application in Xcode, and I need to make it for both iPhone 4 and 5. But since the iPhone 5 has a bigger screen, it messes my application up.
我正在 Xcode 中制作一个应用程序,我需要为 iPhone 4 和 5 制作它。但由于 iPhone 5 有更大的屏幕,它把我的应用程序弄得一团糟。
Once I place the labels for the size of iPhone 4 and then test it on the iPhone 5 the labels are all misplaced. Is there a way to make them stay?
一旦我放置了 iPhone 4 尺寸的标签,然后在 iPhone 5 上进行测试,标签都错位了。有没有办法让他们留下来?
回答by
You can use iOS 6's new autolayoutfeature (if you want to be iOS5-compatible, you can still have autoresizing masks).
您可以使用 iOS 6 的新自动布局功能(如果您想与 iOS5 兼容,您仍然可以使用自动调整大小蒙版)。
回答by Vinod Vishwanath
You need to position your labels based on the View Height of the device(don't have to worry about width, since iPhone 4 and 5 both have the same width. But this would apply for a universal app targeting iPad and iPhone).
您需要根据设备的视图高度来定位标签(不必担心宽度,因为 iPhone 4 和 5 的宽度相同。但这适用于针对 iPad 和 iPhone 的通用应用程序)。
For instance, if yours is a View Based Application, find the view height of the superview using self.view.frame.size.height
, and determine all label/view placements based on this property.
例如,如果您的应用程序是基于视图的应用程序,请使用 找到超级视图的视图高度self.view.frame.size.height
,并根据此属性确定所有标签/视图位置。
And test for both screen sizes on the iOS Simulator.
并在 iOS 模拟器上测试两种屏幕尺寸。