问题描述
我已经为纵向模式下的应用程序开发了所有视图,现在我们计划为用户提供在纵向模式和横向模式之间切换的灵活性,我阅读了一些与此相关的文档,其中他们提供了调整控件位置的选项(x,Y)在xib中基于方向,但是在某些情况下还不够,我需要创建一个新列,因为在这种情况下,与肖像相比,风景将具有更大的宽度,我是否需要创建新视图?或有什么方法可以处理吗?
I have developed all views for my application in portrait mode, Now we are planning to give user flexibility to change between portrait and landscape mode, I have read some documentation related to that, in which they have given option to adjust controls position (X,Y) in xib based on the orientation, but it will not enough in some case, I need to make a new column because landscape will have more width compared to portrait in such cases, Do I need to make new view? or Is there any way to handle?
谢谢
推荐答案
这个问题尚未解决.这实际上取决于您选择的设计以及您要实现的目标.对于某些视图,只需正确设置UIViewAutoresizingMask,就可以轻松地重用它们.这将对其进行拉伸或收缩,或者在调整其父对象的尺寸时使其保持空白.您还可以覆盖layoutSubviews,以更好地控制视图的子视图在更改大小时将执行的操作.另一种设计是将其设计得更高,并使用两个不同的ViewController:一个用于具有完全不同视图的每个方向.当设备旋转时,控制器会以某种奇特的过渡方式交换其视图.因此,您会看到各种各样的选择.
This question is pretty wide open. It really depends on the design you've chosen and what you are trying to accomplish. For some views, they can easily be reused simply by setting the UIViewAutoresizingMask properly. This will stretch or shrink it, or stick to a margin when its parent is resized. You can also override layoutSubviews to have even more control over what a view's subviews will do when it changes size. Another design is to go even a level higher and use two different ViewControllers: one for each orientation with entirely different views. When the device rotates, the controllers swap their views in some sort of fancy transition. So you see you have a variety of options.
这篇关于如何设计一个既适用于横向模式又适用于纵向模式的UIview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!