Search code examples
iosios6mkmapviewmkannotationios6-maps

How to change back annotation pin color to original?


I am change annotation pin color when clicking annotation pin and click another annotation pin change pin color so currently two annotation color changed,but i want currently choosing annotation color only changed old selection back to original color. Thanks in advance


Solution

  • i found a solution create a

    @property (nonatomic, retain) MKAnnotationView *selectedAnnotationView;
    

    in .h file and save when clicked in annotation pin

    - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
    {
    if (self.selectedAnnotationView) {
        self.selectedAnnotationView.image = [UIImage imageNamed:[NSString    stringWithFormat:@"a.png"]];
    }
    self.selectedAnnotationView = view;
    view.image = [UIImage imageNamed:[NSString stringWithFormat:@"b.png"]];
    }
    

    change in .m file