In meiner Anwendung möchte ich, wenn der Benutzer auf eine Annotation für meine UITextviews klickt, um beschreibende Informationen zu dieser Annotation wie Titel, Breite und Länge anzuzeigen. Mein Problem ist, dass ich keine Ahnung habe, wie ich diese Informationen erhalten kann, nachdem die Anmerkungen zur Karte hinzugefügt wurden. Hier ist ein Teil meines Codes, den ich für den MKAnnotationView verwende, der gerade in meinen benutzerdefinierten View-Controller eingebaut ist.Abrufen aktueller Annotationsinformationen in einer Ansicht in xamarin iOS
MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
{
MKAnnotationView annotationView = mapView.DequeueReusableAnnotation(annotationIdentifier);
// Set current location and location of annotation
CLLocationCoordinate2D currentLocation = mapView.UserLocation.Coordinate;
CLLocationCoordinate2D annotationLocation = annotation.Coordinate;
// We don't want a special annotation for the user location
if (currentLocation.Latitude == annotationLocation.Latitude && currentLocation.Longitude == annotationLocation.Longitude)
return null;
if (annotationView == null)
annotationView = new MKPinAnnotationView(annotation, annotationIdentifier);
else
annotationView.Annotation = annotation;
annotationView.CanShowCallout = true;
(annotationView as MKPinAnnotationView).AnimatesDrop = false; // Set to true if you want to animate the pin dropping
(annotationView as MKPinAnnotationView).PinColor = MKPinAnnotationColor.Red;
annotationView.SetSelected(true, false);
_annotationDetailButton = UIButton.FromType(UIButtonType.DetailDisclosure);
_annotationDetailButton.TouchUpInside += (sender, e) =>
{
//put create segue her
PerformSegue("ShowCollectionDetail", Self);
};
annotationView.RightCalloutAccessoryView = _annotationDetailButton;
// Annotation icon may be specified like this, in case you want it.
// annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromBundle("example.png"));
return annotationView;
}
Haben Sie sich meine Antwort angesehen? –
Ich tat, ich bekomme Informationen über die Anmerkungen, aber nicht die, die gerade ausgewählt ist. Ich habe diesen Code der GetViewForAnnotation-Methode hinzugefügt. SculptureTitle.Text = annotationView.Annotation.GetTitle(); Irgendwelche Vorschläge dazu, was ich noch mache, sind falsch. Es scheint, dass ich Anmerkungen nicht auf der aktuellen Anzeige bekomme. – user3020229