Repositioning controls when the orientation changes

Isuru picture Isuru · Feb 18, 2013 · Viewed 8.5k times · Source

I know Auto Layout can be used to make the sizes and position consistent when the orientation changes. Is it possible to completely change the layout when the orientation changes?

For example, please look at the below wire-frame of a simple login screen in portrait mode.

enter image description here

Now if I rotate the device, I want to completely re-position the controls.

enter image description here

Can this kind of a thing be done by using Auto Layout? If not, how should I go about this?

Thank you.

Answer

iphonic picture iphonic · Feb 18, 2013

In your case it can be achieved by two methods, instead of reframing every component you can group the controls like the following..

  1. Parent View -> User Info View -> All User Info controls.. By doing this you will have to just reframe the User Info View not all the controls..

    Then only Logo and Company name left to reframe.. Total 3 controls to reframe if you group your controls..

  2. Create two views one for Portrait and other for Landscape mode, and just add and remove on rotations.. this is the fastest way as you won't have to readjust the frame by tedious code.

Hope above helps.