Accessibility for iOS, VoiceOver read order issue

15,029

Solution 1

The quickest way to achieve this for your example is to place the three labels in a transparent UIView subclass to serve as a container for your labels. This subclass will have to be properly setup to let VoiceOver know how to interpret it. If your deployment target is iOS6 then you can simply answer the "should group accessibility children" question in this subclass.

-(BOOL)shouldGroupAccessibilityChildren{
    return YES;
}

For below iOS6 it would be more complicated, except that your UIView container subclass would contain only UILabels which are accessibility elements. You could implement it like this:

-(BOOL)isAccessibilityElement{
    return NO;
}
-(NSInteger)accessibilityElementCount{
    return self.subviews.count;
}
-(id)accessibilityElementAtIndex:(NSInteger)index{
    return [self.subviews objectAtIndex:index];
}
-(NSInteger)indexOfAccessibilityElement:(id)element{
    return [self.subviews indexOfObject:element];
}

I have tested this example code and it does what you are looking for, if you need any clarification please add a comment. Always happy to help make things more accessible.

Solution 2

I tried setting the shouldGroupAccessibilityChildren to YES but it didn't work for me.

What did work for me was setting the accessibility label of the parent view directly (because I wanted all the items to be read in one go/one VoiceOver gesture).

[cell setAccessibilityLabel:[NSString stringWithFormat:@"%@, %@", cityLabel, temperatureLabel]];

The above snippet of codes is from Apple's documentation Enhancing the Accessibility of Table View Cells

Solution 3

In Swift, attaching an IBOutlet to the parent UIView, then setting shouldGroupAccessibilityChildren to true will suffice.

abc.shouldGroupAccessibilityChildren = true

I did note that if also setting isAccessibilityElement = true the grouping will not take effect. Similarly, checking the accessibility checkbox in the storyboard or xib will also prevent the grouping from taking place.

Share:
15,029
Breakpoint
Author by

Breakpoint

SOreadytohelp

Updated on August 05, 2022

Comments

  • Breakpoint
    Breakpoint over 1 year

    enter image description here

    Is it possible to change the order in which the VoiceOver feature for accessibility in iPad reads out the elements, when the 'Two-finger Flick Down' gesture is done?

    For the attached image, which contains 3 labels and a button, the VoiceOver reads the elements in the following way,

    Label 1 -> Label 2 -> Button -> Label 3

    Can the order be changed to,

    Label 1 -> Label 2 -> Label 3 -> Button