简体   繁体   中英

Rotating Parent View Controller, if Presenting a viewController from NavigationController

I am using a NavigationController in my app and from there, I present a viewController like a popup. So if I rotate the device, I am able to rotate the topView(Presented viewController ) but unable to rotate the parent view controller which is on top of the navigation controller.

I need guidance on why is this occurring and how to resolve this.

If your parent view controller(Presenting view controller) is not a visible view controller, then rotation methods( - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation ) are never called in parent view controller (Presenting view controller). So you should explicitly rotate your view controller based on the status bar orientation. However viewWillLayoutSubviews method will called in your parent view controller when you dismiss your presented view controller. Do the stuff there...

In your parent view controller:

- (void)viewWillLayoutSubviews 
{
    //Check your your view controller is visible. If not visible then call
    [self willRotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation] duration:0];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM