Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repositioning controls when the orientation changes

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.

like image 803
Isuru Avatar asked Feb 18 '13 03:02

Isuru


2 Answers

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.

like image 82
iphonic Avatar answered Sep 20 '22 07:09

iphonic


you cant set frames differently : -

-(void)setFramesForPotrait
{

// set frames here

}

-(void)setFramesForLandscaeMode
{

// set frames here

}

-(bool)shouldAutorotate.....
{
return Yes
}

-()willAutoRotate......
{
if(orientation = uiinterfaceOrientationPotrait)
{
[self setFramesForPotrait];
}
else
{
[self setFramesForLandscape];
}
like image 33
Kasaname Avatar answered Sep 20 '22 07:09

Kasaname