[英]UIImageView rotation (NOT the image, but the view)
How do I rotate the ImageView ... i'm trying to use landscape mode, and have a problem with accelerometer moving the image ... Because when I work in portrait mode the x of accelerometer is the same as the x of the image ... But when I work landscape, the x of accelerometer is the y of the image, because the ImageView autorotates with the parent View. 我如何旋转ImageView ...我试图使用横向模式,并且加速度计移动图像时遇到问题...因为当我在纵向模式下工作时,加速度计的x与图像的x相同...但是当我使用风景时,加速度计的x是图像的y,因为ImageView随父视图自动旋转。 When I rotate the image with CGAffineTransformMakeRotation(M_PI/2), it rotates only the image in it's ImageView... and the x,y sides stays untouched ... Is there any way to make own class which will extend UIImageView where I will swap the x,y sides of a UIImageView ? 当我使用CGAffineTransformMakeRotation(M_PI / 2)旋转图像时,它仅旋转ImageView中的图像...并且x,y面保持不变...是否有任何方法可以使自己的类扩展UIImageView,交换UIImageView的x,y面? Or is there some way to rotate the UIImageView, and not only the image in it? 还是有某种方法可以旋转UIImageView,而不仅仅是旋转其中的图像?
float degree = atan2(accelX, accelY) * 180 / 3.14159;
其中accelX和accelY是来自加速度计的值,请使用度数并旋转ImageView。
Try to convert points depending on orientation... 尝试根据方向转换点...
if( orientation == LANDSCAPE )
{
CGPoint temp;
temp = [touch locationInView:self];
touchPoint.x = temp.y;
touchPoint.y = 320 - temp.x;
}
The above code convert points from portrait to landscape... 上面的代码将点从纵向转换为横向...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.