简体   繁体   English

iPhone 5视图框架的更改

[英]iPhone 5 view frame changes

The app I'm currently working on has a huge number of views. 我当前正在使用的应用程序具有大量的视图。 Some are webviews and some normal UIViews, with a ton of subviews. 一些是Web视图,一些是普通的UIView,带有大量子视图。 Now that the iPhone 5 has come out, how can I most efficiently change the frame size of the entire app to support both 4-inch and 3.5 inch devices? 既然iPhone 5面世了,我如何才能最有效地更改整个应用程序的框架大小,以同时支持4英寸和3.5英寸设备? I certainly could use a whole bunch of if-else statements and layout several frame sizes for each view, but what's the best, most efficient way this could be done? 我当然可以使用一堆if-else语句,并为每个视图布局几种框架大小,但是什么是最好,最有效的方法呢?

Most efficient way is to use one of the provided layouting mechanisms: 最有效的方法是使用提供的布局机制之一:

  1. Autoresizing – Each UIView has property autoresizingMask and by setting it to one or many values (using | operator) you tell the view how to behave when the size of its superview changes. 自动调整大小 –每个UIView都具有autoresizingMask属性,通过将其设置为一个或多个值(使用|运算符),您可以告诉视图当其超级视图的大小更改时如何表现。 Elementary options: 基本选项:

    • UIViewAutoresizingFlexible...
      • ...Width
      • ...Height
      • ...LeftMargin
      • ...RightMargin
      • ...TopMargin
      • ...BottomMargin
  2. Auto Layout – New in iOS 6, it provides more complex (very complicated) mechanism of relations between view attributes. 自动布局 – iOS 6中的新功能,它提供了视图属性之间关系的更复杂(非常复杂)的机制。 Basicaly it is a superset of autoresizing and there are some long docs for it. 基本上,它是自动调整大小的超集,并且有一些很长的文档。 I don't recommend it to you. 我不推荐给你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM