Nella vista MKMap ho personalizzato il pin di annotazione con un'immagine. Ma ancora alcuni pin sono statici e non mostrano l'immagine data.Mostra immagini pin diverse in MKMapview
Sto usando - (MKAnnotationView *) MapView: (MKMapView *) MapView viewForAnnotation: (id) annotazione per impostare l'immagine perno.
Aggiunta il mio codice e schermo qui:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView* pinView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
pinView.animatesDrop=YES;
pinView.canShowCallout=YES;
pinView.pinColor= MKPinAnnotationColorGreen;
pinView.enabled = YES;
pinView.canShowCallout = YES;
pinView.image=[UIImage imageNamed:@"bublerest.png"]; //here I am giving the image
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightButton;
UIImageView *profileIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rest_image2.png"]];
pinView.leftCalloutAccessoryView = profileIconView;
return pinView;
}
Tutte le idee?
Riesci a vedere le tue icone mappa personalizzate per qualsiasi pin o solo alcuni pin non li mostra? – Zhang