7

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

Breakpoint
  • 1,511
  • 1
  • 18
  • 41

4 Answers4

15

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.

NJones
  • 27,139
  • 8
  • 70
  • 88
  • Thank you for that answer. But, the `shouldGroupAccessibilityChildren` doesn't seem to be called. – Breakpoint Oct 31 '12 at 04:34
  • 1
    @Vittal `shouldGroup..` will only called by iOS6 devices not all apps built with >=6 SDK. Also confirm that the view containing your labels is of your custom class in the xib or storyboard using the identity inspector. Let me know if you still have trouble. – NJones Oct 31 '12 at 04:51
  • ah, the custom class part is what i was missing. silly error. It works now. Thanks a lot. and yes i was testing on iOS6. Need to get my hands on version below 6 to test the rest. So just adding the code for below iOS 6, into the custom class will do right? – Breakpoint Oct 31 '12 at 05:00
  • @Vittal I tested this code on an iPod touch 4th gen running iOS6, and an iPad 1st gen running 5.1. Interestingly the 4 pre-6.0 methods were called by both OS versions when implemented, even with `shouldGroup..` implemented. My personal opinion is to leave `shouldGroup..` in your class. it's not unsafe if running pre-6.0 it just won't be called. But if Apple optimizes something in the future, your code will be ready. – NJones Oct 31 '12 at 05:12
  • I noticed the same behaviour :) However, the pre-iOS6 methods dont seem to be working :( Tested on a 2nd gen 5.1 iPad. any idea why – Breakpoint Oct 31 '12 at 06:28
  • @Vittal Not off the top of my head. I would probably try deleting the app and reinstalling, I case the change was not uploaded to the device. Also, try changing the background color of the container to a solid color, sometimes clears act funny. I won't be able to look into this for several hours, but I can't explain the difference between the iPad one and iPad two. Is the behavior the same as without the container view or something different? – NJones Oct 31 '12 at 11:06
  • i believe tried deleting too. Let me try that again. Yes, for 5.1 it seems as though there is no change with or without the view container holding the labels. And thank you for taking such interest in this issue. – Breakpoint Oct 31 '12 at 11:29
  • @Vittal I simply cannot replicate your iPad2 issue on my iPad1, and I don't have an iPad2, and if I did it would probably be running 6.0 by now. I have tried building with Xcode 4.4.1 & 4.5.1 and run on my iPad running 5.1.1. The only other thing I would ask is "Is your iPad2 jailbroken?", I have heard that the jailbreaking process sometimes messes up ancillary frameworks. – NJones Nov 01 '12 at 03:57
  • No difference. Problem is, I dont always have access to an iPad with a 5.1 OS, so its difficult to make changes to the code and check right away. And, no, its not jailbroken. – Breakpoint Nov 02 '12 at 05:24
4

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

ChrisJF
  • 6,822
  • 4
  • 36
  • 41
1

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.

0

I think you can do it in the storyboard. The VoiceOver order is determined by the order of the views in the document outline.

Just drag and drop the views in the view hierarchy in the right order.

David Dunham
  • 8,139
  • 3
  • 28
  • 41
StefanJ
  • 95
  • 6