VoiceOver: force an accessibility element to be selected after a screen transition

kevboh picture kevboh · May 18, 2012 · Viewed 19.4k times · Source

I'm in the process of making my iOS app accessible and I'm nearly finished. My app contains several custom screen transitions, and when VoiceOver is on it seems to pick either the top-leftmost element to describe after the transition or, occasionally, a random element. UIAccessibilityTraitSummaryElement looked promising but as I understand it only works when the app is started, not after arbitrary transitions.

There doesn't seem to be an accessibility trait or property to specify the preferred order that elements are given VoiceOver focus. Is there any way to force VoiceOver focus?

Answer

Patrick Pijnappel picture Patrick Pijnappel · Aug 16, 2012

EDIT: iOS 6 is now available, and as mentioned by kevboh, you can now pass an argument when posting a UIAccessibilityLayoutChangedNotification or UIAccessibilityScreenChangedNotification:

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, myAccessibilityElement);

myAccessibilityElement will in most cases be a UIView with isAccessibilityElement set to YES (the default for many views).

Alternatively, you could add the new trait added in iOS6 UIAccessibilityTraitHeader to your accessibility elements' accessibilityTraits, which should have the same result (although I didn't test this yet).

ORIGINAL: There's new API in iOS 6 that can't be discussed here because it is still under NDA, but can be found in the "Accessibility for iOS" video of WWDC 2012 (Session 210).

Failing that though, a workaround could be to manually trigger a announcement to override the default focused accessibility label announcement:

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, @"Your text");