I have a parent view controller that supports all four orientations. It presents a child view controller, and if the device is rotated while the child view controller is presented, and then you dismiss the child, the parent view controller is not rotated correctly. Here is the code I use for rotation in the parent view controller:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
newestIssueCoverImageButton.frame = CGRectMake(40, 20, 688, 865);
shadow.frame = CGRectMake(40, 20, 688, 865);
recordView.frame = CGRectMake(0, 44, 768, 916);
classifiedsWebView.frame = CGRectMake(0, 44, 768, 916);
} else {
newestIssueCoverImageButton.frame = CGRectMake(269, 20, 486, 613);
shadow.frame = CGRectMake(269, 20, 486, 613);
recordView.frame = CGRectMake(0, 44, 1024, 660);
classifiedsWebView.frame = CGRectMake(0, 44, 1024, 660);
}
The parent looks at though this code wasn’t used and I just rotated the device. How do I call this code and ensure that the parent view controller is rotated correctly when the user is currently looking at the child? Thanks for your help.
From Apple’s docs:
I added a BOOL to track when it is not the top viewController, then:
Works good for me so far.