Created
July 21, 2012 02:39
-
-
Save srm/3154285 to your computer and use it in GitHub Desktop.
Getting the height of a UIWebView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)webViewDidFinishLoad:(UIWebView *)webView{ | |
//Get the height of the web view, and change it's size to fit the content it's displaying. | |
[webView setFrame:CGRectMake(webView.frame.origin.x, | |
webView.frame.origin.y, | |
320, | |
[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"].intValue)]; | |
//Change the scrollview's contentSize to accommodate the new height of the webView. | |
self.scrollView.contentSize = CGSizeMake(320, webView.frame.size.height+webView.frame.origin.y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment