Mein MKPointAnnotation mit diesem Code sollte benutzerdefinierte sein:Warum ist meine MKPointAnnotation nicht benutzerdefiniert?
-(MKPointAnnotation*)setAnnotation: (NSString*) title atLocation:(CLLocationCoordinate2D)Location withImage:(UIImage*) LocationImage{
Pin = [[MKPointAnnotation alloc] init];
Pin.title = title;
[Pin setCoordinate:Location];
[self mapView:mapView viewForAnnotation:Pin].annotation = Pin;
return Pin;
}
-(MKAnnotationView *)mapView: (MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>) annotation{
MKPinAnnotationView* pinView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"CustomPinAnnotationView"];
if(!pinView){
pinView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"CustomPinAnnotationView"];
pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
pinView.enabled = YES;
UIButton *PicButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[PicButton addTarget:self action:@selector(showLocationPicture) forControlEvents:UIControlEventTouchUpInside];\
pinView.rightCalloutAccessoryView = PicButton;
}
else{
pinView.annotation = annotation;
}
return pinView;
}
Doch aus irgendeinem Grund wird die Pin immer noch Standard, kann mir jemand helfen hier? Danke
Aber wie passe ich dann die Einstellungen für die Anmerkung an? weil ich im Moment Dinge wie pinView.rightCalloutAccessoryView = PicButton; aber das funktioniert auch nicht –
@BlackMagic Siehe meine überarbeitete Antwort mit vollständiger Code-Beispiel. – Rob
Vielen Dank, das war genau das, was ich brauchte. –