Note that there are some explanatory texts on larger screens.

plurals
  1. POMvvmCross iOS: How to bind MapView Annotation to jump to another view?
    primarykey
    data
    text
    <p>How can I bind the MapView's annotation to switch to different view when it's callout accessory button is clicked? How do I implement the annotation's CalloutAccessoryControlTapped method?</p> <p>Or what is the best way to do it?</p> <p>Here is my code:</p> <pre><code>[Register("MapView")] public class MapView : MvxViewController { public override void ViewDidLoad() { Title = "Map"; base.ViewDidLoad(); var mapView = new MKMapView(new RectangleF(0, 0, 320, UIScreen.MainScreen.Bounds.Height - 20 - 44)) { MapType = MKMapType.Standard, ZoomEnabled = true, ScrollEnabled = true, Delegate = new MapDelegate(), }; View.AddSubview(mapView); var center = new CLLocationCoordinate2D(ViewModel.CurrentLat, ViewModel.CurrentLong); var span = new MKCoordinateSpan(5.0, 5.0); var region = new MKCoordinateRegion(center, span); mapView.SetRegion(region, true); mapView.AddAnnotation(CreateNewAnnotation(ViewModel.CurrentLat, ViewModel.CurrentLong, "You are here")); var set = this.CreateBindingSet&lt;MapView, MapViewModel&gt;(); set.Bind(mapView).For(???).To(vm =&gt; vm.showDetailCommand); // how can I bind to the map annotation and switch to other view when user click it? set.Apply(); } protected class MapDelegate : MKMapViewDelegate { public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, MonoTouch.Foundation.NSObject annotation) { var pinId = "locationPinId"; var pinView = (LocationAnnotationView)mapView.DequeueReusableAnnotation(pinId) ?? new LocationAnnotationView { Annotation = annotation, RestorationIdentifier = pinId, Image = UIImage.FromBundle("images/map_pointer_icon_small.png"), }; var buttonView = new UIButton(new RectangleF(0, 0, 27, 27)); buttonView.SetImage(UIImage.FromBundle("images/blue_arrow.png"), UIControlState.Normal); buttonView.Tag = 88888; pinView.RightCalloutAccessoryView = buttonView; return pinView; } public override void CalloutAccessoryControlTapped(MKMapView mapView, MKAnnotationView view, UIControl control) { // how can I bind this method, so when the user click on the annotation it can switch to other view? } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload