I'm using the Acapela TTS on iOS. I have a HTML document with all the text (and markup) that I want read out. The text is split in paragraphs and I want to be able to start the TTS at each header. At the moment I put each paragraph in it's own UIWebView (for handling the internal markup) and add these to a UIScrollView for navigating all the elements. Each UIWebView is overloaded with a button, so when it's pressed, the connected text is read aloud. My problem now, is that I have to place the UIWebView and Buttons using a frame (meaning a static y-position), but this entails that I have the exact height, which is my current problem. I have tried using the solutions mentioned in this question: UIWebView height, but it still doesn't look good - either the webviews are too high or short, and I need it to be perfect, so it looks like a consistent webpage.
Does anybody know of a different way of doing this type of TTS without splitting it up in separate webviews that I have overlooked?
This is my code that place the UIWebViews:
float yOffset = 0;
UIWebView *previous = nil;
//UIWebView delegate
-(void)webViewDidFinishLoad:(UIWebView *)webView{
NSString *height = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
if(previous!=nil){
yOffset += previous.frame.size.height;
}
CGFloat h = [height floatValue];
CGRect frame = CGRectMake(0, yOffset, scrollView.frame.size.width, h);
[webView setFrame:frame];
[webView setOpaque:NO];
[webView setBackgroundColor:[UIColor whiteColor]];
previous = webView;
[scrollView addSubview:webView];
yOffset += previous.frame.size.height;
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width, yOffset)];
}