Question

I have created UITableViewCell, that contains 2 objects:

  1. UILabel - Used to show title text.
  2. UIWebView- Used to show HTML.

Normally when Voice focus UITableViewCell, it read all added labels without any problem, but in my case, voice over only reads title and not the webview html content, user has to swipe right and left to move to next/previous element to read the content of webview.

My requirement is that when voice focus UITableViewCell, voice should read UILabels and webview content in one go, because as a developer we know its a HTML, but for app user(blind) doesn't have any idea about it.

Also I want to know that how to disable UIWebview accessibility. I tried by setting isAccessibility to NO, but still Voice Over focus UIWebview. [self.webview setIsAccessibilityElement:NO];

How to solve this problem?

Was it helpful?

Solution

I have resolved this problem by implementing method "accessibilityLabel" inside table cell view. For webview fetch web view content, convert html into plain text and use it. Don't forget to disable label and webview accessibility.

-(NSString*)accessibilityLabel{

NSString *labelText=nil;
NSMutableString *cellLabelText=[[NSMutableString alloc] init];

//Set label
[cellLabelText appendString:[NSString stringWithFormat:@", %@", self.titleLabel.text]];

//Fetch web view content, convert html into plain text and use it.
NSString *html = [self stringByEvaluatingJavaScriptFromString: @"document.body.innerHTML"];
NSString *plainText=[self convertHTMLIntoPlainText:html];

[cellLabelText appendString:plainText];


labelText=[NSString stringWithString:cellLabelText];
[cellLabelText release];


return labelText;
}


-(NSString *)convertHTMLIntoPlainText:(NSString *)html{

NSScanner *myScanner;
NSString *text = nil;
myScanner = [NSScanner scannerWithString:html];

while ([myScanner isAtEnd] == NO) {

    [myScanner scanUpToString:@"<" intoString:NULL] ;

    [myScanner scanUpToString:@">" intoString:&text] ;

    html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>", text] withString:@""];
}
//
html = [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

return html;
}

OTHER TIPS

How about:

[self.webview setAccessibilityElementHidden:YES]

Then set whatever accessibility label you like on the cell with the accessibilityLabel property.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top