1
votes

I remove all "red rubber bands" in IB and locate the square UIView exactly in the center. It does not jump when rotating between landscape and portrait modes. When I create the same in my code with

myView.autoresizingMask = UIViewAutoresizingNone;

and make necessary frame adjustments in

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

it jumps to new position.

Where is a trick?

1

1 Answers

3
votes

IB's logic is a bit different from what you do through code. Well, it certainly is possible to do the very same in code but IB takes things from a different angle.

If what you actually want is the same that IB results to when disabling ALL springs, then you actually want to use the following combination.

UIViewAutoresizingFlexibleRightMargin | 
UIViewAutoresizingFlexibleLeftMargin | 
UIViewAutoresizingFlexibleTopMargin | 
UIViewAutoresizingFlexibleBottomMargin

Is equal to

enter image description here