I have a iPad application which goes between two states, one using a SplitView the other a TableView.
Currently I have a single UIWindow object, and switch between views with the following code
-(void) switchToStateA {
[viewControllerB.view removeFromSuperview];
[window addSubview:viewControllerA.view];
}
-(void) switchToStateB {
[viewControllerA.view removeFromSuperview];
[window viewControllerB.view];
}
Everything works fine unless I change the device orientation. After changing orientation and switching states, the state which was not active during the change is still in the frame of its old state (leaving black areas at the edge of the display). If I change the orientation again the new state will be fixed.
I've tried adding
[viewControllerA.view setNeedsLayout];
after swapping the views but it did not have an effect.
How do I make sure the background view controllers get the orientation callback, or how do I invoke a 'refresh' when I switch state?