Search code examples
ios7mkmapviewmkannotationmkannotationviewmkmapviewdelegate

Map custom annotation is not showing in device


I am changing my pin annotation view by this code:

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

    if([annotation isKindOfClass:[MKUserLocation class]])
        return nil;
    static NSString *identifier=@"myAnnotation";

    MapObjects *annotation1=(MapObjects*)annotation;
    MKPinAnnotationView * annotationView = (MKPinAnnotationView*)[self.map_whereAreVehicles dequeueReusableAnnotationViewWithIdentifier:identifier];
    if(!annotationView){
        annotationView= [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
        annotationView.image=[UIImage imageNamed:@"greenpin.png"];
        annotationView.animatesDrop = NO;

        annotationView.canShowCallout = NO;
    }
    else{
        annotationView.annotation=annotation;
    }
    return annotationView;
}

This is showing me image in simulator. But when I am testing in ipad it is not showing anything there. If I remove image then default pin is shown in both.And one more thing in device annotation is there but it is not visible only.


Solution

  • Maybe the problem is your file name. The simulator is case insensitive, the device is not. Please ensure that you are using the right file names.