I am using the iphone sdk and trying to use a custom image for my AnnotationView on my MKMapView. My approach works fine for another screen in my app, but for the problematic one, I see the image in the simulator but not on the device. I basically create a custom view like this:
@implementation CustomAnnotationView
- (id) initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [ super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier ])
{
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
self.image = [UIImage imageNamed:@"MapIcon.png"];
}
return self;
}
@end
Then in the getViewForAnnotation method I do this:
// attempt to reuse
CustomAnnotationView* annotationView = (Custom AnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@""];
// if reuse failed, create a new one
if (annotationView == nil)
{
annotationView = [[Custom AnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@""];
}
return annotationView;
It works in the simulator but never in the device. If I stop using a custom view it places the red pin in both (i.e. it works). Has anyone seen a discrepancy like this?