How to fix the height of tableviewcell based on webview height? (i am loading webview in each tableviewcell)
iphone, objective-c, uitableview
Solution
To get the height of `UIWebView` object, first you need to load them. Then inside the delegate method of `UIWebView` you can get the height as per the html content like given below.
- (void)webViewDidFinishLoad:(UIWebView *)webView {
NSLog(@"%f",myWebView.scrollView.contentSize.height);
}
you can also get the height of `UIWebView` by JS insertion like this
[myWebView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"];
In `webViewDidFinishLoad` method you have to store height based on webview object tag.
After that load your table and in below method give height accordingly.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Problem
// `I am loading **HTML file** in **UIWebview** which is located on **tableviewcell**.` I want to fix height for cell based on HTML file height. Note: loading HTML file will be different for every cell.(height is not constant for every HTML file)