I know there was a question about this before. However, I think a little bit noob because I can’t get it solved.
I’m getting that error when trying this:
MKAnnotation *annotation = [[MKAnnotation alloc] initWithCoordinate:coordenada title:@"HELLO!"];
[mapa addAnnotation:annotation];
I also have the following method:
- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation: (id<MKAnnotation>) annotation
{
MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.mapa dequeueReusableAnnotationViewWithIdentifier: @"asdf"];
if (pin == nil)
{
pin = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"asdf"] autorelease];
}
else
{
pin.annotation = annotation;
}
pin.pinColor = MKPinAnnotationColorRed;
pin.animatesDrop = YES;
return pin;
}
And did the #import < MapKit/MKAnnotation.h> in header.
Any help please?
Thank you very much!
MKAnnotationis a protocol, not a class that you can instantiate.Have you defined your own class that implements
MKAnnotationand ainitWithCoordinate:title:method? If you have, use that class name and import its header file.If you haven’t created your own annotation class, you’ll have to create one or you can use the pre-defined
MKPointAnnotationclass (in iOS 4+) instead:You’ll also need to do the following:
#import <MapKit/MapKit.h>at the top of the filedelegateproperty (or outlet in IB) of the map view otherwiseviewForAnnotationwon’t get called