Question

I am using the built in setDataDetectorTypes: method to auto-detect phone numbers in my UITextViews. This works great for 99% of cases for phone numbers like 1800 47 47 53.

I am setting this detection in code using the following (content is a UITextView):

        [content setDataDetectorTypes: UIDataDetectorTypePhoneNumber];

As expected, this method doesn't just see all number strings as phone numbers. I have a phone number in my text, "13 74 68", that is not being detected because it probably doesn't look like a phone number.

Is there any way I can force the dataDetector to see this number as a phone number? Or is there some padding/formatting I can do to the number string instead?

Was it helpful?

Solution

If you know something is going to be a phone number, you can add the NSLinkAttributeName attribute with a value of tel:137468 and it's going to be handled as if it had been detected by Data Detectors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top