I have a UINavigationController which's view is embedded into UIViewController. When I rotate the device, NavigationController perfectly received the willRotate
didRotate
events. However, any UIViewControllers pushed before the current visible view controller inside UINavigationController does not receive rotation events.
Here is the problem: While the second viewController is visible in the navigationController, if I rotate the device, ViewController changes it's layout according to the rotation. When I pop the viewcontroller to get back to first view controller, first view controller shows itself according to portrait layout as It doesn't call my re-layouting methods for the rotated view.
I don't want to add observers for rotation change because it normally already behaves correctly as default rotation methods are automatically called normally...
What can I do in this situation?
I have done it by manually calling willRotate function but I don't feel that this is good.
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
UIInterfaceOrientation io=[[UIApplication sharedApplication] statusBarOrientation];
[self willRotateToInterfaceOrientation:io duration:0.3];
for(int i=0;i<self.childViewControllers.count;i++){
[[self.childViewControllers objectAtIndex:i]willRotateToInterfaceOrientation:io duration:0.3];
}
}