我想在 iOS 地图视图的点击点添加一个小子视图,这样当我滚动和缩放地图视图时,添加的子视图也会缩放和滚动。有什么帮助吗?我尝试过的代码如下:
- (void)viewDidLoad
{
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(foundTap:)];
tapRecognizer.numberOfTapsRequired = 1;
tapRecognizer.numberOfTouchesRequired = 1;
[self.myMapView addGestureRecognizer:tapRecognizer];
}
- (IBAction)foundTap:(UITapGestureRecognizer *)recognizer
{
CGPoint point = [recognizer locationInView:self.myMapView];
dotimage = [[UIView alloc]initWithFrame:CGRectMake(point.x,point.y , 10, 10)];
dotimage.backgroundColor = [UIColor redColor];
[self.myMapView addSubview:dotimage];
}
视图dotimage
不随地图视图移动和滚动。