VoiceOver controls are selectable when hidden
Matthew Barrera
I have a UIView which contains some controls (e.g. buttons, labels, etc). I overlay this view onto another view (using addSubview). If the user has VoiceOver on, he can swipe left and right to select the controls. However if I hide the view so the controls are no longer visible, the user is still able to swipe and select them (although they don't actually work). Since this is very confusing to a blind user, I would like to keep this from happening. I have even tried removing the view that contains the controls (using removeFromSuperview) but the user can STILL swipe to select them (although the little boxes which highlights them are no longer in the correct positions). It is like VoiceOver has memorized that those controls were once there and will remember that forever more.
I also found the property 'accessibilityElementsHidden' and I have tried setting that to YES on the view which contains the controls when it is hidden, but that does not seem to work either.
Is this a bug in VoiceOver, or am I missing something? Is there a workaround?
Thanks.
12 Answers
The "memorized" part makes me think you aren't doing something like UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil) after removing the subviews.
The documentation for "accessibilityElementsHidden" states:
A Boolean value indicating whether the accessibility elements contained within this accessibility element are hidden. ..... The default value for this property is NO. You might use this property to hide views that are covered by the arrival of a new view. In this case, the hidden views might remain visible onscreen, but they are not the focus of the user’s actions.
You might also use this property to hide a transient view that VoiceOver users don’t need to notice. For example, VoiceOver doesn’t need to describe the translucent view that appears when users adjust the volume on their devices, because the aural feedback of this action is sufficient.
So based on this, in order to have those subviews ignored by VoiceOver, you'd actually want to set this to "YES" on the parent view.
1