Modal view does not allow rotation of other views

I have this method in my MainViewController:

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { NSLog(@"MAIN CONTAINER WILL ANIMATE"); [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; } 

And when I spin, NSLog appears, and everything is perfect. However, if I present a modalViewController from my MainViewController and then rotate, the NSLog no longer appears and my MainViewController never knows that the device has rotated, so when the modalView is fired, the interface is not configured to rotate.

Any ideas on why a modal view might prevent parents from receiving rotation updates? Is this typical, or is something wrong with my setup?

And just to make sure, I tried to present modalViewController as a subview via [mainViewController.view addSubview:modalView.view] , and rotation updates took effect properly. This only happens when I do [mainViewController presentModalViewController:modalViewController]; that updates do not take effect.

+2
ios objective-c iphone
source share
3 answers

Of course, when a view controller is presented modally, no other controllers receive any messages at all. This is what modally means in this context.

An obvious solution would be to check the orientation in the viewWillAppear method of your modeless visibility controller.

+4
source share

You should check the implementation:

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Overriden to allow any orientation. return YES; } 

In both views.

+1
source share

You need to adjust the layout to the current interface orientation in viewWillAppear. Obviously, since the view is not visible, the animation functions will not be called until the modal view controller is running.

0
source share

All Articles