Software orientation of the interface, but the keyboard orientation is not the same as in the status bar on iOS 8

Basically I want my application to show in portrait, but the user can manually change the orientation of the interface in some ViewControllers.

MyNavigationVC → press VC1 in portrait → press VC2 in portrait mode by default → click button to go to landscape.

So, I check the orientation of the device on portrait, landscape left, landscape rightin the .plist file. And in the topmost navigation controller, I redefine the method as follows:

//MyNavigationVC : UINavigationController
- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

, , VC1 , VC2 , FullScreen, . , :

- (void)onFullScreenButtonTouchUpInside:(id)sender
{
    [self changeViewFrameToFullScreen];
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
}

iOS6/7, iOS8.

iOS 8 .

iOS 8 , . ( ), .

iOS 8? , ? .

+4
2

:

- (void)onFullScreenButtonTouchUpInside:(id)sender
{
    [self adjustViewFrameToFullScreen];
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
    //change the device orientation
    if (IsIOS8) {
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
    }
}
+3

, :

// Note that UIInterfaceOrientationLandscapeLeft is equal to UIDeviceOrientationLandscapeRight (and vice versa).
// This is because rotating the device to the left requires rotating the content to the right.

[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
0

All Articles