Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Buttons in customized callout views cannot be tapped

$
0
0

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.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>