旋转后的UIImageView touchLocationInView不正确

问题描述:

我有一个UIImageView,当我触摸它,我可以得到触摸的位置:旋转后的UIImageView touchLocationInView不正确

[touch locationInView:theUIImageView] 

的问题是,当我旋转的UIImageView有:

theUIImageView.transform = CGAffineTransformMakeRotation(DegreesToRadians(arc4random()%15)); 

[touch locationInView:theUIImageView]不再返回水龙头的正确位置! *喘气!

关于如何获得real tap location的任何建议?

在locationInView中选择不同的(可能是父级,不旋转的)视图。如果你需要一个不同的坐标系统,你可以在旋转前根据UIImageView的框架添加自己的偏移量。

+0

请您详细说明一下吗?我不确定你想要解释什么 – Parad0x13 2012-04-11 01:50:20

+0

你可以调用locationInView来获取视图中的位置。您碰巧正在使用旋转的图像视图,但您可以通过将它传递给locationInView来获取父视图内的触摸位置。 – Nick 2012-04-11 01:53:36