mostly I want my app show in portrait, but the user can manually change the interface orientation in some ViewControllers.
MyNavigationVC -> push VC1 in portrait -> push VC2 in portrait default -> press a button to switch to landscape.
So, I check device orientation to portrait, landscape left, landscape right
in .plist file. And in the top-most NavigationController, I have override the method like this:
//MyNavigationVC : UINavigationController
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
Assuming that I want VC1 show in portrait always, and Push VC2 in portrait by default, but user can press FullScreen
button to switch to landscape. So, I changed the status bar's orientation in the button action:
- (void)onFullScreenButtonTouchUpInside:(id)sender
{
[self changeViewFrameToFullScreen];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
}
Everything is ok on iOS6/7, But not iOS8.
The orientation of the keyboard on iOS 8 is not the same as status bar.
On iOS 8, the status bar is in landscape, but the keyboard will show in portrait. Only if the user turn the device to landscape manually(and the interface orientation is also in landscape), then the keyboard will show in landscape.
Is this a bug of iOS 8? What could I do to fix it? Thanks.