Forum Xamarin.iOS

Make a phone number initiate a phone call when tapped?


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?



  • PhilippeLeybaertPhilippeLeybaert BEMember ✭✭
    edited November 2012

    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))
  • Philippe,
    Thanks. Just tried that and I'm getting no response to the tap. Hmmmm.

  • 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;
  • Ha! I literally JUST remembered to set that. It's firing the event now. THANK YOU!

Sign In or Register to comment.