私のアプリケーションでは、ユーザーが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