iPhone - 从垂直切换到水平时防止 UIImageView 旋转
我有一个带有相机覆盖层的应用程序。
在这个覆盖视图中,我有 2 个 imageView 和 1 个视图。 1 个用于叠加图形绘制的图像视图。
我将拍摄的照片放入图像视图中。
我为一些自定义绘图自定义视图。
当 iPhone 处于水平位置拍照时,图像视图中显示的照片会旋转。所以我的图片两边都有很大的空间。
我尝试将其放入 OverlayViewController 但没有任何效果:
shouldAutorotateToInterfaceOrientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
所有视图和图像视图在 IB 中具有相同的参数(对于那些常见的参数)。
当手机不垂直时如何防止图片旋转到图像视图?
注意:我必须能够保持自动旋转可以在应用程序中显示的其他视图的能力。
I have an app with a camera overlay.
Into this overlay view I have 2 imageViews and 1 View.
1 image view for overlay graphic drawing.
I image view to put the taken picture into it.
I custom View for some custom drawing.
When the iPhone is in horizontal position when taking the photo, the displayed photo into the image view is rotated. So I have a big space on both sides of the picture.
I've tried to put this into the OverlayViewController but without any effect :
shouldAutorotateToInterfaceOrientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
All view and image view have the same params into IB (for those params that are common).
How may I prevent the picture to rotate into the image view when the phone is not vertical ?
Note : I must be able to keep the ability to auto rotate the other views that I can display in the app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在视图控制器的
willAnimateRotationToInterfaceOrientation:duration:
方法中,您可以对 UIImageView 的transform
属性应用相反的旋转。例如,如果控制器旋转到 UIInterfaceOrientationLandscapeLeft,即从纵向顺时针旋转 90°。因此,如果对图像视图应用 90° 逆时针旋转,它看起来根本没有旋转。In your view controller's
willAnimateRotationToInterfaceOrientation:duration:
method, you can apply an opposite rotation to the UIImageView'stransform
property. For example, if the controller is rotating to UIInterfaceOrientationLandscapeLeft, that is a 90° clockwise rotation from portrait. So if you apply a 90° counterclockwise rotation to the image view, it will seem to not have rotated at all.您可以直接将其添加到窗口,该窗口不会自动旋转。
You can add it to the window directly, which won't auto-rotate.