How to setup accessibility for all table cell contents in iOS?

| | August 4, 2015

I setup the accessibility for the table cell successfully. But I have two cases:

If I set the accessibility to self.containerview, I need to tap on each element and it gives the voice over for each element.

If I set the accessibility to self, the voice over is reading the cell content except the image view. Somehow, the voiceover is neglecting the image view and is only reading the uilabels.

This is how I setup the accessibility:

-(void)awakeFromNib{
 [UIViewController makeViewAccessible:self]; //tried self.containerView, If i put self here, voice over is not reading the imageview
 }

and the method:

 +(void)makeViewAccessible:(UIView *)view {
for(UIView *subview in [view subviews]){
     if([subview isMemberOfClass:[UIView class]]){
        [self makeStaticViewAccessible:subview];
    }else if([subview isMemberOfClass:[UILabel class]]){
        [subview setIsAccessibilityElement:YES];
        [subview setAccessibilityTraits:UIAccessibilityTraitStaticText];
    }  else if([subview isMemberOfClass:[UIImageView class]]){
        [subview setIsAccessibilityElement:YES];
        [subview setAccessibilityTraits:UIAccessibilityTraitImage];
    }
  }
}

One Response to “How to setup accessibility for all table cell contents in iOS?”

  1. You should disable accessibility of self and self.containerView.
    Ex: [self.containerView setIsAccessibilityElement:NO]

    Now you can set accessibility of each subviews, by using your custom method(+(void)makeStaticViewAccessible:(UIView *)view).

Leave a Reply