I use the following code to change the portrait view to landscape landscape and it works great.
But I need to know that after changing the view to the landscape, when I print the current orientation of the device, it gives me the "Portrait" mode.
Can this code change the orientation of the device? if so, why does it show as the "Portrait" mode when I check the current orientation?
So how can I change the device orientation in a documented way?
Please help me ...
Please see my code below.
[[UIApplication sharedApplication] setStatusBarOrientation:
UIInterfaceOrientationLandscapeRight];
UIScreen *screen = [UIScreen mainScreen];
CGFloat screenWidth = screen.bounds.size.width;
CGFloat screenHeight = screen.bounds.size.height;
UIView *navView = [[self navigationController] view];
navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
navView.transform = CGAffineTransformIdentity;
navView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
[UIView commitAnimations];
source
share