[英]Rotated UIImageView touchLocationInView not correct
I have a UIImageView
and when I touch it I can get the location of the touch with:我有一个
UIImageView
,当我触摸它时,我可以通过以下方式获得触摸的位置:
[touch locationInView:theUIImageView]
The problem is that when I rotate the UIImageView with:问题是当我旋转 UIImageView 时:
theUIImageView.transform = CGAffineTransformMakeRotation(DegreesToRadians(arc4random()%15));
the [touch locationInView:theUIImageView]
no longer returns the correct location of the tap! [touch locationInView:theUIImageView]
不再返回点击的正确位置! *gasp! *喘气!
Any suggestions on how to get the real tap location
?关于如何获得
real tap location
的任何建议?
Choose a different (possibly parent, something not rotated) view to use in locationInView.选择一个不同的(可能是父视图,未旋转的视图)在 locationInView 中使用。 If you need a different coordinate system from there, you can always add your own offsets based on the frame of theUIImageView before the rotation.
如果你需要一个不同的坐标系,你总是可以在旋转之前根据 UIImageView 的框架添加你自己的偏移量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.