bobby grenier
bobby grenier

Reputation: 2130

iphone programming objective-c : mkannotation Pin problem

i tryed to make a customized pin on the map with green color and with a button. but it doesnt work. I have a class named Placemark that implement mkannotation protocol. This is my method that supposed to show a green pin but it doesnt:

- (MKAnnotationView *) map:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>) annotation{
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
    annView.pinColor = MKPinAnnotationColorGreen;
    annView.animatesDrop=TRUE;
    annView.canShowCallout = YES;
    annView.calloutOffset = CGPointMake(-5, 5);
    return annView;
}

i also want to specified that my MKMapview is called "map" and its an IBOutlet.

thanks

Upvotes: 0

Views: 692

Answers (1)

user467105
user467105

Reputation:

The method name must be mapView:viewForAnnotation:. The map view looks specifically for that name. You can change the internal parameter variable names but not the parts before the colons.

Try this:

- (MKAnnotationView *) mapView:(MKMapView *)map 
                            viewForAnnotation:(id <MKAnnotation>) annotation

With that misspelling, the map view doesn't call your viewForAnnotation method and must be putting a default red pin on the map.

Upvotes: 1

Related Questions