0

I am trying to disable accessibility for all of the UI elements that appear on my screen. Afterwards my plan is to re-enable only specific elements based on the user's interactions with the app.

I've been trying to accomplish this by passing self.view to the following method:

- (void)disableSubviewsOfView:(UIView *)view
{
    NSArray *subviews = [view subviews];
    for (UIView *subview in subviews)
    {
        [subview setIsAccessibilityElement:NO];
        [self disableSubviewsOfView:subview];
    }
}

It should be noted that for some reason the guy that originally wrote this code decided to stack UIViews on top of each other so there are elements still appearing in the background.

I'm wondering, is there a way that I can disable accessibility of ALL elements, not necessarily just the ones contained in a specific UIView?

Taluca
  • 45
  • 2
  • 8
  • That seems like a lot of work. Wouldn't you want most of your views to be accessible? – David Rönnqvist Apr 14 '15 at 07:51
  • Yes, but the only elements that should be accessible at any given time are the ones that are actual visible on the screen. Does that make sense? For example, in the code I'm working with it's not uncommon to find a button or a text field hidden behind the front-most visible view. So while the button or text field is not actually being presented it is highlighted when swiping through accessible elements. – Taluca Apr 14 '15 at 20:13

2 Answers2

6

From your comment, it sounds like you're attempting to prevent VoiceOver users from interacting with occluded views (eg. views blocked by a modal view). Try setting accessibilityViewIsModal to YES on your topmost view to instruct accessibility clients to ignore interaction with siblings of that element.

Justin
  • 20,509
  • 6
  • 47
  • 58
1

You can disabled the accessibility of each element in storyboard/xib files.

UIAccessibility in interface

After in code you can enable the elements you need.

view.IsAccessibilityElement = YES;

This can help you, but i think that in your situation the upper answer is better.

SlavisWolf
  • 29
  • 7