How to design a UIview which will work for both La

2019-08-29 23:41发布

问题:

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?

Thanks,

回答1:

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.



回答2:

i think for simple designs you can you uiautoresizingmask for use orientation method for change frames of controls