2

I have a list of 15 questions each of them again have sub questions, I'm showing these questions on webView which is present in tableViewCell. Below to this webView there are three labels and three buttons. Now problem is that I'm not getting the heights of tableViewCell based on webView's content. Please suggest me a good solution and thanks in advance. Here is my code in webviewdidfinishload

- (void)webViewDidFinishLoad:(UIWebView *)aWebView {
    int fontSize =160;
    NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%d%%'", fontSize];
    [aWebView stringByEvaluatingJavaScriptFromString:jsString];
    CGRect frame = aWebView.frame;
    frame.size.height = 1;
    aWebView.frame = frame;
    CGSize fittingSize = [aWebView sizeThatFits:CGSizeZero];
    frame.size = fittingSize;
    aWebView.frame = frame;
    NSLog(@"size: %f, %f", fittingSize.width, fittingSize.height);
}
nikhil84
  • 3,235
  • 4
  • 22
  • 43
mahesh
  • 97
  • 3
  • I got some links so you could go through it [link1](http://stackoverflow.com/questions/17204967/how-to-change-the-height-of-webview-dynamically), [link2](http://stackoverflow.com/questions/10715524/calculate-uiwebview-height-depending-on-its-content) and [google search](https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=change+webview+height+as+per+webview+content&spell=1). Also I don't think that giving different height's to tableViewCell will look nice and also webView content would be dynamic. So better to give a standard height making app look pleasant. – nikhil84 Jun 04 '14 at 07:12
  • It is not possible to give standard heights because the questions are coming from json service and all of the questions are not of fixed length. – mahesh Jun 04 '14 at 07:25
  • could you provide some screen shots? – nikhil84 Jun 04 '14 at 07:28
  • I just surfed the net and got that some web pages are correctly scaled, but some are not. For web pages which are not properly scaled, javascript can be used to control zooming as follows: **NSString *jsCommand = [NSString stringWithFormat:@"document.body.style.zoom = 1.5;"]; [webLookupView stringByEvaluatingJavaScriptFromString:jsCommand];** Also here is the [link](http://stackoverflow.com/questions/1511707/uiwebview-does-not-scale-content-to-fit) – nikhil84 Jun 04 '14 at 08:24
  • Problem for me is just height issue, is there any possibility to change the uitableviewcell height based on webview content? – mahesh Jun 04 '14 at 08:51
  • Nope ,there isn't any way to do so. You could change content size of UIWebView to fit as per size of cell or UIWebview size Or you could create a webpage as per you require containing table , buttons ,etc and load it on UIWebView. – nikhil84 Jun 04 '14 at 09:02
  • How can i create a webpage suggest me any tutorials please – mahesh Jun 04 '14 at 09:12
  • You could create a webpage using html, php, dreamweaver or python but from my side I would suggest to go for html as it's easy to learn. For webpage using [html link](http://www.w3schools.com/html/DEFAULT.asp). Don't forget to vote up ! – nikhil84 Jun 04 '14 at 09:16

0 Answers0