I have a UINavigationController as my UIWindow's rootViewController and a UIViewController (ControllerA) that supports only Portrait orientation is added to the UINavigationController as its rootViewController.
At some point later, I replace UINavigationController's rootViewController with a new UIViewController (ControllerB). ControllerB supports both Portrait and Landscape. I want my initial screen (ControllerA) to only work in Portrait while the rest of the app can supports both Portrait and Landscape.
[self.navigationController setViewControllers:@[viewControllerB] animated:NO];
| UINavigationController launches:
| ----ControllerA (rootViewController): Portrait only
| ----ControllerB (rootViewController): Portrait and Landscape supported
If I start my app in Landscape which is not handled by ControllerA and then move to ControllerB, my content (+status bar) is still in Portrait. If I manually rotate the device at this point, I have the correct content layout.
How can I make ControllerB render itself in the orientation of the device?
Here's what I'm seeing from both ControllerA and ControllerB viewWillAppear method:
navigationController orientation: UIInterfaceOrientationPortrait
UIViewController interfaceOrientation: UIInterfaceOrientationPortrait
<!-----------!!two values are different!!------------------>
[[UIDevice currentDevice] orientation]: UIDeviceOrientationLandscapeLeft
[[UIApplication sharedApplication] statusBarOrientation]: UIInterfaceOrientationPortrait
Phone is physically held in Landscape at this point in time.