How to Rotate ViewController Manually?

0

I started a project, where I use a CustonNavigationController to control the navigation of the screens.

In this project, only one viewcontroller can be rotated to landscape mode. But the following problem occurs as follows:

1 - Launch the app in portrait 2 - Navigate to the screen 3 - Rotates the device and the screen enters landscape mode 4 - Keeping the app in landscape mode, I go back to the previous screen, the app is still landscape and not rotational to portrait.

In other words: In CustomNavigationContoller, I determined that only 1 screen could be rotated to landscape mode. However, when returning to the previous screen the orientation is maintained in landscape mode.

How could you rotate the canvas that is in landscape to to portrait before it is removed?

I tried to use the code below, but to no avail:

-(void)viewWillDisappear:(BOOL)animated{

    if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
        ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {

        NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
        [[UIDevice currentDevice] setValue:value forKey:@"orientation"];

    }
}
    
asked by anonymous 07.04.2015 / 19:20

1 answer

0

Try this.

 
#define degreesToRadians(x) (M_PI * x / 180.0)

self.view.transform = CGAffineTransformRotate(self.view.transform, degreesToRadians(-90));
    
19.06.2015 / 22:05