В моем приложении я хотел бы, когда пользователь нажмет аннотацию для моих UITextviews, чтобы показать более подробную информацию об этой аннотации, например название, широта и долгота. Моя проблема: я понятия не имею, как получить эту информацию после добавления аннотаций на карту. Вот некоторые из моего кода, который я использую для MKAnnotationView, который только что встроен в мой пользовательский контроллер представлений.Получение текущей информации о аннотации для отображения в представлении в 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;
}
Вы посмотрели мой ответ? –
Я сделал, я получаю информацию об аннотациях, но не тот, который в настоящее время выбран. Я добавил этот код к методу GetViewForAnnotation. SculptureTitle.Text = annotationView.Annotation.GetTitle(); Любые предложения о том, что я все еще делаю неправильно. Кажется, я получаю аннотации не на текущем дисплее. – user3020229