Custom UITableViewCell trouble with UIAccessibility elements

Posted by ojreadmore on Stack Overflow See other posts from Stack Overflow or by ojreadmore
Published on 2010-11-09T02:13:44Z Indexed on 2011/01/18 3:53 UTC
Read the original article Hit count: 197

No matter what I try, I can't keep my custom UITableViewCell from acting like it should under the default rules for UIAccessiblity. I don't want this cell to act like an accessibility container (per se), so following this guide I should be able to make all of my subviews accessible, right?! It says to make each element accessible separately and make sure the cell itself is not accessible.

- (BOOL)isAccessibilityElement
{
    return NO;
}

- (NSString *)accessibilityLabel
{
    return nil;
}

- (NSInteger)accessibilityElementCount
{
    return 0;
}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier //cells use this reusage stuff
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) 
    {
        [self setIsAccessibilityElement:NO];
        sub1 = [[UILabel alloc] initWithFrame:CGRectMake(0,0,1,1)];
        [sub1 setAccessibilityLanguage:@"es"];
        [sub1 setIsAccessibilityElement:YES];
        [sub1 setAccessibilityLabel:sub1.text]

        sub2 = [[UILabel alloc] initWithFrame:CGRectMake(0,0,1,1)];
        [sub2 setAccessibilityLanguage:@"es"];
        [sub2 setIsAccessibilityElement:YES];
        [sub2 setAccessibilityLabel:sub2.text]

The voice over system reads the contents of the whole cell all at once, even though I'm trying to stop that behavior. I could say

        [sub2 setIsAccessibilityElement:NO];

but that would would make this element entirely unreadable. I want to keep it readable, but not have the whole cell be treated like a container (and assumed to be the English language). There does not appear to be a lot of information out there on this, so at the very least I'd like to document it.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c