Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAccessibility - containers

There's a "containers" rotor setting in voiceover - it allows you to quickly navigate through "high level" sections of the screen (swipe up and down). For example in calendar you have 3 items - navbar , contents, toolbar.

My app uses custom UIView subclasses and no matter what I try to do - all my views seem to belong to a single container - so i can't split them into logical sections. I tried putting them in separate views implementing UIAccessibilityContainer protocol and setting few of the accessibility properties on these parent views.

Does anyone know how to create multiple containers?

like image 863
Filip Lukasik Avatar asked Dec 17 '14 10:12

Filip Lukasik


1 Answers

I did some digging on this issue and think its a private trait Apple is using. First I noticed the only containers recognized are standard UIKit type objects like UITableViews, UITabBars, UINavigationBars, etc. So next I used the debugger to inspect the value of the accessibility traits for these components. They're all 0x200000000000. Just to be sure I didn't miss an UIAccessibilityTrait I checked all of their values. None of them match the value. Furthermore if you set your views accessibility traits to this mysterious value it'll work just like you want! I tried determining the location of this constant but didn't have much luck. If you want to do more digging it looks like apple stores accessibilityTraits using an NSObject category that uses associated objects with some constant value named AXTraitsIdentifier.

Practically speaking you could do something like the below but since its not defined in a public API its functionality could 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 one else has info on this? So far I haven't found an ideal solution.

like image 115
AtlasMeh-ed Avatar answered Sep 18 '22 16:09

AtlasMeh-ed