Tap Gesture Recognizer on a UILabel

wallymwallym USInsider, Beta ✭✭✭

I'm working up an example using the UITapGestureRecognizer on a label. I would think that this would work. Unfortunately, my TapCarrierLabel method is never being called. Any ideas? Source code below. is there something about the scrollview potentially grabbing the gesture recognizer? (Yeah, I am still pretty Hungarian after all these years.)

public override void ViewDidLoad ()
{
        base.ViewDidLoad ();
    // Perform any additional setup after loading the view, typically from a nib.
    uisv = new UIScrollView ();
        uisv.Frame = this.View.Bounds;
        View.Add(uisv);
        var halfScreenDisplay = this.View.Bounds.Width / 2;
    labelCarrier = new UILabel ();
        labelCarrier.Frame = new RectangleF(startingPointX, startingPointY, halfScreenDisplay - deltaX, standardControlHeight);
        labelCarrier.Text = "Carrier";
        uisv.Add(labelCarrier);
        labelCarrierTitle = new UILabel();
        labelCarrierTitle.Frame = new RectangleF(startingPointX, labelCarrier.Frame.Bottom + deltaY, halfScreenDisplay - deltaX, standardControlHeight);
        labelCarrierTitle.Text = "Select a Carrier";
        uisv.Add(labelCarrierTitle);
        uitgr = new UITapGestureRecognizer(TapCarrierLabel);
        labelCarrierTitle.AddGestureRecognizer(uitgr);
        uiasCarrier = new UIActionSheet();
    }

    public void TapCarrierLabel(UITapGestureRecognizer uitgr)
    {
        var uiav = new UIAlertView("Test", "Test", null, "Ok", null);
        uiav.Show();
    }

Posts

Sign In or Register to comment.