1

I have a UITextView that displays attributed string with links in it. When I run Accessibility Inspector, it can correct detect the UITextView as static text, and list the links as children with correct UIAccessibilityTraitLink. Now I need to get those elements from my own code. But UITextView doesn't return any of the inner accessibility elements. What interface does Accessibility Inspector go through to find the child elements? The attached screenshot is what Accessibility Inspector sees:

enter image description here

Haitao Li
  • 1,695
  • 16
  • 25
  • "But UITextView doesn't implement any of the UIAccessibilityContainer methods" What do you mean by "doesn't implement"? – matt May 05 '17 at 04:54
  • @matt [textView accessibilityElementCount] returns 0x7fffffffffffffff and [textView accessibilityElements] returns nil – Haitao Li May 05 '17 at 04:56
  • Okay, but that is "implementing" them. It implements them to return zero and nil, but it implements them. — I'm having trouble figuring out where you see the links as children in the Accessibility Inspector. – matt May 05 '17 at 05:01
  • @matt I rephrased my question and attached Accessibility Inspector screenshot. – Haitao Li May 05 '17 at 05:06
  • It's funny, I just don't see that on my machine. – matt May 05 '17 at 05:13
  • Do you add a link to the attributed string? – Haitao Li May 05 '17 at 05:19
  • I'm running Accessibility Inspector 5.0 and iOS simulator. – Haitao Li May 05 '17 at 05:20
  • What do you want exactly? Find all the links? If you use `NSAttributedString` or `NSDataDetector`, it's possible, no use to go with Accessibilty that seems to higlight them in the inspector. You can get then the Text that is marked as a link, and the URL attached. See there: http://stackoverflow.com/questions/28595378/get-text-range-of-link-in-uitextview/28595578#28595578 – Larme May 05 '17 at 15:02

0 Answers0