when a user makes a screenshot with the press of homebutton and powerbutton than is the screenshot upside down. The device does never autorotate. I observe UIDeviceOrientationDidChangeNotification
and if it is in landscape, I will show the rotated view. Depending on left or right device orientation
This happens when I show a view that is rotated with this code
CGAffineTransform rotationTransform = CGAffineTransformIdentity;
rotationTransform = CGAffineTransformRotate(rotationTransform, DEGREES_TO_RADIANS(90));
landscape.transform = rotationTransform;
Here are the rotation methods of the viewcontroller
- (BOOL)shouldAutorotate {
return NO;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
I disable autorotate and force the rotation:
- (void)forceOrientationChange {
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
CGAffineTransform rotationTransform = CGAffineTransformIdentity;
switch (deviceOrientation) {
case UIDeviceOrientationFaceDown:
case UIDeviceOrientationFaceUp:
case UIDeviceOrientationPortrait:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
break;
case UIDeviceOrientationLandscapeLeft: {
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
rotationTransform = CGAffineTransformRotate(rotationTransform, DEGREES_TO_RADIANS(90));
landscape.transform = rotationTransform;
break;
}
case UIDeviceOrientationLandscapeRight: {
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
rotationTransform = CGAffineTransformRotate(rotationTransform, DEGREES_TO_RADIANS(-90));
landscape.transform = rotationTransform;
break;
}
default:
break;
}
}