我有一个带有相机叠加层的应用。
在这个叠加 View 中,我有 2 个 ImageView 和 1 个 View 。
1个用于叠加图形绘制的 ImageView 。
我 ImageView 将拍摄的照片放入其中。
我为一些自定义绘图自定义 View 。
当 iPhone 处于水平位置拍照时,显示的照片进入 ImageView 是旋转的。所以我在图片的两边都有很大的空间。
我试图将其放入 OverlayViewController 但没有任何效果:
shouldAutorotateToInterfaceOrientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
所有 View 和 ImageView 在 IB 中具有相同的参数(对于那些通用的参数)。
当手机不是垂直时,如何防止图片旋转到 ImageView 中?
注意:我必须能够保留自动旋转我可以在应用中显示的其他 View 的能力。
最佳答案
在 View Controller 的 willAnimateRotationToInterfaceOrientation:duration:
方法中,您可以对 UIImageView 的 transform
属性应用相反的旋转。例如,如果 Controller 旋转到 UIInterfaceOrientationLandscapeLeft,则从纵向顺时针旋转 90°。因此,如果您对 ImageView 应用逆时针旋转 90°,它似乎根本没有旋转。
https://stackoverflow.com/questions/5628950/