Reputation: 183
Every once in a while my Web View will encounter a site that is zoomed in too far, I don't care about vertical scrolling but horizontal scrolling can be very annoying. My code thus far:
-(void)zoomToFit
{
webView.scalesPageToFit = YES;
NSInteger height = [[webView stringByEvaluatingJavaScriptFromString:
@"document.body.scrollHeight"] integerValue];
NSInteger width = [[webView stringByEvaluatingJavaScriptFromString:
@"document.body.scrollWidth"] integerValue];
NSLog(@"%d %d",height,width);
}
As you can see I have the height and width of the page I just don't know how to change the "zoom"
Upvotes: 0
Views: 154
Reputation: 1544
You can set the contentSize
of UIWebView
's UIScrollView
. Like:
[yourWebView.scrollView setContentSize:CGSizeMake(width,height)];
Hope this will work for you.
Upvotes: 1