First HTML file content
Index.html<Html><Body><DivId= "Content"Contenteditable= "false"Style= "Font-family:helvetica"> <a href= "Id:abc" Style= "Text-decoration:none; Color:green "> John a>: this was out Rich Text Editing View </div ></body></html>
Loading HTML files
-(void) viewdidload{ [Super Viewdidload]; Additional setup after loading the view, typically from a nib. NSBundle *mainbundle = [NSBundle mainbundle]; Nsurl *indexfileurl = [Mainbundle urlforresource:@ "index" withextension:@ "html"] ; [Self.webview loadrequest:[nsurlrequest requestwithurl:indexfileurl];}
Calculate the actual height after WebView display content
Two methods, Method 1 can get the actual height of the content, method 2 Get the content display complete after the WebView size (including uiedgeinsets)
- (void) Webviewdidfinishload: (UIWebView *) wb{//Method 1 CGFloat documentwidth = [WB stringbyevaluatingjavascriptfromstring:@"document.getElementById (' content '). offsetwidth"] Floatvalue]; CGFloat documentheight = [WB stringbyevaluatingjavascriptfromstring:@"document.getElementById (\"Content\"). offsetheight;"] Floatvalue]; NSLog (@"DocumentSize = {%f,%f} Documentwidth, documentheight); // Method 2 CGRect frame =7681; wb.scrollView.scrollEnabled = NO; wb.frame = frame; Frame.size.height = Wb.scrollView.contentSize.height; NSLog (@ "frame =%@, [Nsvalue Valuewithcgrect:frame]); Wb.frame = frame;}
:
IOS: Calculating the content height of UIWebView