2
votes

I have a root UIViewController (VC1), inside a UINavigationController, which handles rotation by adjusting its views/subviews frames manually in the willRotateToInterfaceOrientation: method. The rotation works fine if the root UIViewController is the active view controller, basically on top of the stack.

The problem occurs when i push another UIViewController (VC2) onto the NavigationController. I then rotate VC2 which works fine. However when i pop VC2 the problem is that VC1 has not rotated to the correct orientation, nor does its willRotateToInterfaceOrientation: method get called?? The shouldAutorotateToInterfaceOrientation: method in VC1 is called but thats it.

My question then is how am i supposed to make sure that my UIViewController VC1 has been updated for the current orientation for this type of situation??

1

1 Answers

1
votes

The way I resolve this is to check on viewWillAppear: to see if the orientation is now different to when viewDidDisappear was called. If so I call the code to layout the view.

To adopt this approach first factor the code responsible for laying out the view into something like _layoutViews, can simply call it as required in viewWillAppear as well as in willRotateToInterfaceOrientation:.