Hi, This might be considered as sth sequel to forums.xamarin.com/discussion/10306/how-to-customize-map-callout#latest.
I've implemented custom callout, in which two buttons are defined, in DidSelectAnnotationView method as follows:
public override void DidSelectAnnotationView (MKMapView mapView, MKAnnotationView view)
{
// show an image view when the conference annotation view is selected
if (view.Annotation is BasicMapAnnotation) {
_annotation = (BasicMapAnnotation)view.Annotation;
_calloutView = PrepareCalloutView (new MapDemoViewController ()
, _annotation.VetId
, _annotation.Title
, _annotation.Distance
, _annotation.NoOfComments
, _annotation.PhoneNumber
, _annotation.UserCoordinate);
view.Add (_calloutView);
}
}
Below is how I defined the buttons in the UIView (which is a product of PrepareCalloutView)
//btnInfo = new UIButton ();
btnInfo = UIButton.FromType (UIButtonType.Custom);
btnInfo.SetBackgroundImage (UIImage.FromFile ("tooltipinfoicon.png"), UIControlState.Normal);
//btnInfo.BackgroundColor = UIColor.White;
btnInfo.TouchUpInside += (sender, e) => {
var DetailViewController = new VetDetailScreenAlternate (vetId, userLocCoord);
vc.NavigationController.PushViewController (DetailViewController, true);
};
But when I tapped on the buttons TouchUpInside event doesn't work, instead (maybe as expected) DidDeselectAnnotationView method below is called and callout becomes invisible. Most probably the button tap is considered as a tapping anywhere else on the map.
public override void DidDeselectAnnotationView (MKMapView mapView, MKAnnotationView view)
{
// remove the image view when the conference annotation is deselected
if (view.Annotation is BasicMapAnnotation) {
_calloutView.RemoveFromSuperview ();
_calloutView.Dispose ();
_calloutView = null;
}
}
Is there anyone who knows how I can make button clicks work, or whether it is possible? Thanks.