UIWebView獲得內容的高-作出自適應高的UIWebView – iPhone手機開發技術文章 iPhone軟體開發教學課程

[cpp]  

– (void)webViewDidFinishLoad:(UIWebView *)webView  

{      

NSString *height_str= [webView stringByEvaluatingJavaScriptFromString: @"document.body.offsetHeight"];  

    int height = [height_str intValue];  

    webView.frame = CGRectMake(0,0,320,height);  

    NSLog(@"height: %@", [webView stringByEvaluatingJavaScriptFromString: @"document.body.offsetHeight"]);  

}  

You May Also Like