Search code examples
iosaccessibilityswitchcontrol

How to programmatically group items when using switch control of IOS?


When using the Switch Control accessibility feature of iOS, you can turn on "Group Items" to improve the scanning speed.

But does anyone know, how the system decides which controls should be grouped together and which should not?

I have tried laying out the controls in many different ways, but still cannot figure out the logic.

Thanks


Solution

  • It looks like this should do it:

    https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIAccessibility_Protocol/index.html#//apple_ref/occ/instp/NSObject/shouldGroupAccessibilityChildren

    For example, consider an app that shows items in vertical columns. Normally, VoiceOver would navigate through these items in horizontal rows. Setting the value of this property to YES on the parent view of the items in the vertical columns causes VoiceOver to respect the app’s grouping and navigate them correctly.

    So, give the grouped items a common superview, and set shouldGroupAccessibilityChildren to true.