Make a phone number initiate a phone call when tapped? RRS feed

  • Question

  • User129 posted


    I have a UILabel (currently) on my view that displays a phone number. I want to make that phone number initiate a call when tapped. I've searched around and found info about making it a "tel:" hyperlink, but that doesn't work for me. The UILabel just shows the code. How exactly do I force this to be a link? Or is there a better way to do it?

    Thanks, Bob

    Monday, November 19, 2012 2:00 PM

All replies

  • User774 posted

    You can add a "tap" gesture recognizer to the label and have it execute a call to OpenUrl() on UIApplication:

     UITapGestureRecognizer tap = new UITapGestureRecognizer(
            () => UIApplication.SharedApplication.OpenUrl(new NSUrl("tel:" + label.Text))
    Monday, November 19, 2012 2:36 PM
  • User129 posted

    Philippe, Thanks. Just tried that and I'm getting no response to the tap. Hmmmm.

    Monday, November 19, 2012 3:52 PM
  • User774 posted

    I forgot to mention that you should set UserInteractionEnabled to true:

    var tap = new UITapGestureRecognizer(
        tap => UIApplication.SharedApplication.OpenUrl(new NSUrl("tel:" + label.Text))
    label.UserInteractionEnabled = true;
    Monday, November 19, 2012 4:19 PM
  • User129 posted

    Ha! I literally JUST remembered to set that. It's firing the event now. THANK YOU!

    Monday, November 19, 2012 4:22 PM