How can I take zooming into account when a user touches a UIScrollView?
Posted
by Bill
on Stack Overflow
See other posts from Stack Overflow
or by Bill
Published on 2010-06-06T18:48:38Z
Indexed on
2010/06/06
18:52 UTC
Read the original article
Hit count: 181
iphone
I have a UIImageView inside of a UIScrollView. The parent scroll view allows zooming and panning. When the user taps a point in the scroll view, I want to find the location in the raw image inside the UIImageView - i.e. I want the point after including any zooming and panning the user has done in the scroll view.
Right now, I have a UIScrollView subclass called ForwardingScrollView that handles touch events and attempts to convert them into locations in the coordinate system of the child image view. I tried adding contentOffset to these points, tried multiplying them by zoomScale, and even tried doing both. I also tried calling [touch locationInView: self] and [touch locationInView: parent], but none of these methods correctly return the point that I clicked in the underlying image.
What's the best way to do this?
Thanks in advance.
© Stack Overflow or respective owner