【发布时间】:2014-04-25 09:05:29
【问题描述】:
当用户按下主页按钮和电源按钮进行屏幕截图时,屏幕截图会上下颠倒。设备从不自动旋转。我观察UIDeviceOrientationDidChangeNotification,如果它是横向的,我将显示旋转视图。取决于设备的左右方向
当我显示使用此代码旋转的视图时会发生这种情况
CGAffineTransform rotationTransform = CGAffineTransformIdentity;
rotationTransform = CGAffineTransformRotate(rotationTransform, DEGREES_TO_RADIANS(90));
landscape.transform = rotationTransform;
这里是viewcontroller的旋转方法
- (BOOL)shouldAutorotate {
return NO;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
我禁用自动旋转并强制旋转:
- (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;
}
}
【问题讨论】:
-
但是你从不改变界面方向?
-
嗨大卫,我更新了我的问题。
标签: ios rotation core-graphics screenshot