简体   繁体   中英

Rotated UIImageView touchLocationInView not correct

I have a UIImageView and when I touch it I can get the location of the touch with:

[touch locationInView:theUIImageView]

The problem is that when I rotate the UIImageView with:

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

the [touch locationInView:theUIImageView] no longer returns the correct location of the tap! *gasp!

Any suggestions on how to get the real tap location ?

Choose a different (possibly parent, something not rotated) view to use in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM