I have made this implemention of MKAnnotionView:
- (MKAnnotationView*) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
NSString *identifier = @"mypin";
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if(annotationView == nil)
{
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationView.canShowCallout = YES;
UIImageView *pin = [[UIImageView alloc] initWithImage:[UIImage imageNamed:identifier]];
UIImageView *shadow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pin_shadow"]];
shadow.frame = CGRectMake(21, 36, 60, 27);
[annotationView addSubview:shadow];
[annotationView addSubview:pin];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(0, 0, 11, 20);
[btn setImage:[UIImage imageNamed:@"arrow"] forState:UIControlStateNormal];
annotationView.rightCalloutAccessoryView = btn;
annotationView.centerOffset = CGPointMake(-(44.0f/2), -62.0f);
}
return annotationView;
}
The pins and shadows show up fine on the map but when i press a pin the callout is now shown. I am positive that the annotation objects have a title and a subtitle value.
If i add my pin using the .image property on the MKAnnotionView it works but then my shadow is on top of the pin.. mehh! :/
What is going wrong?