0
votes

I have class

@interface MyLocation : NSObject <MKAnnotation> 

@property (copy) NSString *name;
@property (copy) NSString *address;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, strong) UIImage *banner;
@property (nonatomic, strong) NSString *descr;

When I add location on map i want that method - (MKAnnotationView*) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation show banner .... how can i do this?

    - (MKAnnotationView*) mapView:
(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
    {
    static NSString *identifier = @"MyLocation";
    if ([annotation isKindOfClass:[MyLocation class]]) {
        MKPinAnnotationView *annotationView = (MKPinAnnotationView*)
        [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];

        if (annotationView == nil) {
            annotationView = [[MKPinAnnotationView alloc] 
    initWithAnnotation:annotation reuseIdentifier:identifier];
                        } else {
                            annotationView.annotation = annotation;
                                }
                annotationView.enabled = YES;
                annotationView.canShowCallout = YES;
                annotationView.image = [UIImage imageNamed:@"Image2.jpg"];

                return annotationView;
        }
        return nil;
    }

this method change all annotation pins but i need differed images for each annotation. Thanks for help!

2

2 Answers

0
votes

You have to use MKAnnotationView for custom pins, since MKPinAnnotationView always displays the "default" pins.

0
votes

custom CLASS MKAnnotationView, and U can change the pins see the sample code from apple:map callouts