-1

I want to open dialer on click of label consisting of mobile number in swift 3 iOS.Please help me with this.

Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
Naina
  • 49
  • 5
  • You Question is not clear can you give more information and show some code what you had try out – Bhupat Bheda Apr 25 '17 at 10:31
  • follow this link http://stackoverflow.com/questions/27259824/calling-a-phone-number-in-swift – ami rt Apr 25 '17 at 10:34
  • Do we need to import cocoa in order to convert NSUrl to url because it is showing error cannot convert value NSURL to type URL in coercion. @ ami rt – Naina Apr 25 '17 at 11:11

1 Answers1

1

You can't make links clickable in a label unless you do it yourself with a gesture recognizer.

I suggest using a UITextView instead. You can turn off editing and make it look just like a label, then enable phone number detectors, set yourself up as the delegate of the text view, and dial the number when the user taps it. Take a look at the textView(_:shouldInteractWith:in:interaction:) UITextViewDelegate method. You should be able to find example code showing how to do it.

EDIT:

I have a project on Github called DatesInSwift that uses clickable text fields as I've described, although it uses a custom URL scheme that links back to the app rather than dialing a phone number like you want. The idea is very similar, though, and you should be able to use the sample app as a guide.

Community
  • 1
  • 1
Duncan C
  • 128,072
  • 22
  • 173
  • 272