mardi 4 août 2015

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

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 makeStaticViewAccessible:self]; //tried self.containerView, If i put self here, voice over is not reading the imageview
 }

and the method:

 +(void)makeStaticViewAccessible:(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:[UIButton class]]){
        [subview setIsAccessibilityElement:YES];
        [subview setAccessibilityTraits:UIAccessibilityTraitButton];
    } else if([subview isMemberOfClass:[UIImageView class]]){
        [subview setIsAccessibilityElement:YES];
        [subview setAccessibilityTraits:UIAccessibilityTraitImage];
    } else if([subview isMemberOfClass:[UITextField class]]){
        [subview setIsAccessibilityElement:YES];
        [subview setAccessibilityTraits:UIAccessibilityTraitSearchField];
    }
}

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire