views:

15

answers:

1

Hi all,

I am implementing MAPKit Based application, In that I had a problem with the pins display. Some times they are coming on top of the callOut view. I used the following code to send the pins back,

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
 {
          for (MKAnnotationView* annotationView in views) 
         {

              [mapView sendSubviewToBack:annotationView];
         }
}

Please help me if miss any thing, it is very urgent.

Thanks in advance,

S.

A: 

Can't remember if the callout bubble is a subview of the annotationView, if it is the following should work... If you're coding for iOS 4.0 and above you can use these

- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)annotView {
     [mapView sendSubviewToBack:annotView];
}

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)annotView {  
     [mapView bringSubviewToFront:annotView];   
}

Otherwise try implementing inside the annotationView

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint point = [touch locationInView:self];
    if ([self pointInside:point withEvent:event]) {
        UIView *mySuperview = self.superview;
        while (mySuperview && ![mySuperview isKindOfClass:[MKMapView class]]) {
            mySuperview = mySuperview.superview;
        }
        if (mySuperview) {
            [mySuperview bringSubviewToFront:self];
        }
    }
}

Hope this helps

tsakoyan