I want to add a small subview at tap point on an iOS map view in such a way that added subview also zooms and scrolls when I scroll and zoom the map view. Any help? The code I have tried is below:
- (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];
}
The view dotimage
is not moving and scrolling with the map view.