Skip to content

Instantly share code, notes, and snippets.

@a-bx
Created December 13, 2011 16:02
Show Gist options
  • Save a-bx/1472684 to your computer and use it in GitHub Desktop.
Save a-bx/1472684 to your computer and use it in GitHub Desktop.
How to reset UIWebView's zoom
UIScrollView *sv = nil;
// if iOS5 the scrollView property exists!
if ([self.webView respondsToSelector:@selector(scrollView)])
sv = webView.scrollView;
else
sv = [webView.subviews objectAtIndex:0];
CGSize theSize = [sv contentSize];
CGRect theFrame = [sv frame];
CGFloat zoomScale = theFrame.size.width / theSize.width;
[sv setContentOffset:CGPointZero animated: YES];
[sv setZoomScale:(zoomScale) animated:YES];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment