UIAccessibility - containers

The voice acting has a container "rotator" that allows you to quickly navigate the "high-level" sections of the screen (swipe up and down the screen). For example, the calendar has 3 elements - navbar, content, toolbar.

My application is using custom UIView subclasses and no matter what I try to do - all my views seem to belong to the same container, so I cannot break them down into logical sections. I tried to put them in separate views that implement the UIAccessibilityContainer protocol and set several accessibility properties for those parent views.

Does anyone know how to create multiple containers?

+3


source to share


1 answer


I did a little work on this issue and consider it a private trait that Apple uses. At first I noticed that the only recognized containers are standard UIKit type objects such as UITableViews, UITabBars, UINavigationBars, etc. So, I used a debugger to check the meaning of the accessibility flags for these components. They are all 0x200000000000. To make sure I didn't miss the UIAccessibilityTrait, I checked all of their values. None of them match the value. Plus, if you set your accessibility traits to this mysterious value, it will work the way you want it to! I tried to locate this constant, but I had no luck. If you want to do more digging, it looks like Apple's accessibility stores that use the NSObject category.which uses related objects with some constant value named AXTraitsIdentifier.

Practically you can do something like below, but since it is not defined in the public API, its functionality may change in the future



//Note the navBar has to be run through a voice over pass before the value is set :( or you can just directly set the value to 0x200000000000.
myContainerView.accessibilityTraits = navBar.accessibilityTraits;

      

I'd love to hear if anyone else has information on this? So far, I haven't found a perfect solution.

+1


source







All Articles