0

I have added an image on annotation view and when i am touching annotation view its image is changeing into red pin can any one tell me what's he reason for it

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 
{
    MKPinAnnotationView* newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"];

    if (annotation == _mapView.userLocation)
    {
        newAnnotation.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        return nil;
    }

    //[newAnnotation setSelected:YES];
    newAnnotation.image = [UIImage imageNamed:@"sample.png"];
    newAnnotation.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    newAnnotation.canShowCallout = YES;
    [newAnnotation retain];

    return newAnnotation;

}
visakh7
  • 26,380
  • 8
  • 55
  • 69
Manish Jain
  • 865
  • 3
  • 13
  • 28

1 Answers1

1

Make the newAnnotation a MKAnnotationView rather than a MKPinAnnotationView.

visakh7
  • 26,380
  • 8
  • 55
  • 69