1

我有一个包含缩放图像的 UIImageView。图像大小为 3264 x 2448,UIImageView contentMode 设置为 AspectFit。UIImageView 的大小为 320 x 427。我有以下视图层次结构:

WorkspaceView : UIView
   -> UIImageView (Contains the image)
   -> A UIView which contains a UITapGestureRecognizer

我目前正在尝试基于 UIImageView (具有较大的 XY 坐标空间 - 2448)从触摸中获取坐标。UIView 基于它自己的视图而不是它的父视图引发触摸。它封装了 UITapGestureRecognizer 以便引发委托调用。

当给定 UIView 内的坐标时,如何获得缩放的 XY 触摸点?我已经尝试了以下代码,但它似乎不起作用:

- (void)lineView:(LineView *)aLineView requestsDistanceForLine:(Line *)line {
   // aLineView is the subview
   // line contains the startpoint and endpoint of the aLineView - it's the model
   // capturedImageView is the local instance of the scaled UIImageView
   CGPoint startPoint =[self convertPoint:[line startPoint] toView:self.capturedImageView];
}

startPoint 最终太小了。有什么想法吗?

4

1 回答 1

1

原来有人已经解决了这个问题。这是它的 github 存储库的链接。

https://github.com/nubbel/UIImageView-GeometryConversion

于 2013-03-04T23:46:37.990 回答