8

There's a "Containers" rotor option in Voiceover which allows the user to quickly navigate through "high level" sections of the screen via single finger swipe up and swipe down actions. For example, the Calendar app has three high level items: navbar, contents and 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. I can't split them into logical sections. I tried putting them in separate views implementing the UIAccessibilityContainer protocol and setting a few of the accessibility properties on the parent views.

Does anyone know how to create multiple containers?

Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
  • possible duplicate of [UIAccessibilityContainer in child view controllers?](http://stackoverflow.com/questions/27524569/uiaccessibilitycontainer-in-child-view-controllers) – Justin Dec 17 '14 at 21:37
  • no - unfortunately it does not answer my question. the question is how to create multiple containers (really important - containers in this case mean "Containers" setting on the voiceover rotor, not objects implementing UIAccessibilityContainer). – Filip Lukasik Dec 18 '14 at 08:54

2 Answers2

7

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.

AtlasMeh-ed
  • 469
  • 5
  • 7
  • 1
    This feels so dirty. But it works. Any more information on this in the intervening years since? – mgray88 May 27 '20 at 14:27
1

I have been able to make the views in my app reachable by single finger swipe up and swipe down actions when the "Containers" rotor option is selected by setting the accessibilityContainerType property of my views to semanticGroup.

Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
  • You're right , `semanticGroup` is the appropriate value to be used for an iOS app regarding the container types (source⟹ https://stackoverflow.com/a/75609772/3825084). – XLE_22 Mar 01 '23 at 22:53