I have added the custom view in Map when user tap on the Pin maker in the map it will show the uiview ontop of the pin maker but the problem is when i scroll the Map the custom is not scrolling with the map pin please tell me how to resolve this issue.
My code.
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
test = [[UIView alloc]initWithFrame:CGRectMake(view.frame.origin.x - 12.5, view.frame.origin.y - 45, 50, 50)];
test.backgroundColor = [UIColor yellowColor];
[mpview addSubview:test];
}
-(void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
{
test.frame = CGRectZero;
}
I have used the above code please tell me how to make the view to scroll with the pin maker in map
Thanks in Advance.
In this case you should add the test
not to mapView but to the selected annotation view
. Just update the position until it fit your needs.
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
test = [[UIView alloc]initWithFrame:CGRectMake(-10,-25, 50, 50)];
[view addSubview:test];
}
don´t forget to remove the view when you don`t need it anymore.