I figured that using my own custom pin image for annotations would be super easy. But, I have never been able to get it to work, and I have no idea why! I am simply using:
Annotation *anno = [[[Annotation alloc] init] autorelease];
anno.coordinate = ridesMap.userLocation.location.coordinate;
anno.title = @"Current Location";
anno.subtitle = [NSString stringWithFormat:@"%f, %f", anno.coordinate.latitude, anno.coordinate.longitude];
static NSString *defaultPinID = @"LocationIdentifier";
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[ridesMap dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinView == nil){
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:anno reuseIdentifier:defaultPinID] autorelease];
}
pinView.image = [UIImage imageNamed:@"custom_pin.png"];
pinView.opaque = NO;
pinView.canShowCallout = YES;
pinView.draggable = NO;
pinView.annotation = anno;
NSLog(@"Adding current location annotation");
return pinView;
I assumed that this should work, as a UIImage is what it is wanting, and I do have the custom_pin.png file in my project.
It never uses my image, but just the standard red pin. What am I doing wrong here?