开发者

How can I take zooming into account when a user touches a UIScrollView?

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 subcla开发者_开发问答ss 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.


UIView has methods for converting points and rectangles between views.

[scrollView convertPoint:somePoint toView:imageContentView];

or

[imageContentView convertPoint:somePoint fromView:scrollView];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜