문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top