Reputation: 375
I have a detail page with a fairly standard layout, a scrollview which hosts one vertical stack view, which in turn hosts UITextView
s or vertical textviews which each contain a heading and a "content" textview. This is a screenshot from Interface Builder:
I want all headings to be reachable with the built-in accessibility rotor "Headings". However, I can't get it to work. Voiceover correctly reads all labels in the right order. All Textviews have the "accessibility element" tick selected and some of them the "heading" tick. All of them have the "user interaction enabled" tick as a preselected value.
However, when I inspect them using the Accessibility Inspector, all of them only list "static text" as their traits, which was not selected in IB. I also tried setting or adding the .header
trait to them in the viewDidLoad()
method to no success like this:
myTextView1.accessibilityTraits.insert(.header)
myTextView2.accessibilityTraits = [.header]
I tried this with static textviews who get their text through IB, and also textviews that get populated with text from a database, no success. The only place where heading navigation works is a static tableview where voiceover correctly identifies tableviewHeaders as headings, without any help. Line navigation using the "line" rotor works as intended out of the box.
Am I missing something or is this a bug?
This question seems do deal with a similar problem. This persons solution was to run it on a real device. While this handles other simulator voice-over glitches correctly, it does not solve my problem. Other similar questions (like here) often deal with the problem inside table view cells, who cause problems due to the accessibility hierarchy. I believe this is not the case here, since all views are found and read correctly.
Upvotes: 0
Views: 415
Reputation: 1396
You can customize the headings rotor to include specific parts of your textView by initializing a custom rotor using the system type UIAccessibilityCustomRotor.SystemRotorType.heading
. You can also add heading attributes to your attributed string. For more info, see https://developer.apple.com/videos/play/wwdc2020/10116/.
Upvotes: 0