Search code examples
iosvoiceover

VoiceOver controls are selectable when hidden


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.


Solution

  • The "memorized" part makes me think you aren't doing something like UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil) after removing the subviews.