【发布时间】:2011-07-03 20:45:54
【问题描述】:
我的应用程序有一个 UIScrollView 和一个 UIView 作为子视图。两者尺寸相同。 scrollView 包含一个大图像,子视图是一个“覆盖”视图,其中包含在用户点击大图像(地图)时设置的标记。它基本上是一个简单的应用程序,允许在地图上的某些位置设置标记。
到目前为止一切顺利。设置标记和滚动 scrollView 工作(标记保持在地图上的位置)。但是,还有一个问题。当我放大/缩小时,标记(在叠加视图中)的位置不正确(当我放大时标记移动到左上角)。我已经尝试使用 convertPoint() 方法转换标记位置,但不幸的是没有成功。
我的 UIView 层次结构如下所示:
[mapScrollView addSubview:mapImageView]; // mapScrollView obviously is the scrollview. it holds
// an UIView with an image (map).
[mapScrollView addSubview:mapImageAnnotationView]; // UIView that holds annotations (markers)
[mapImageView addGestureRecognizer:singleTap]; // handle taps
[mapImageView addGestureRecognizer:doubleTap];
[mapImageView addGestureRecognizer:twoFingerTap];
[self addSubview:mapScrollView]; // self is the container UIView that holds the composition
大小/绑定设置:
mapImageView = [[UIImageView alloc] initWithImage: mapImage]; // init with image file
mapScrollView.contentSize = CGSizeMake(mapImageView.frame.size.width,mapImageView.frame.size.height);
mapScrollView.clipsToBounds = YES;
mapImageAnnotationView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mapImageViewWidth, mapImageViewWidth)];
谁能指出我正确的方向来解决这个问题?
谢谢
【问题讨论】:
-
感谢您格式化代码 aBitObvious