Created
December 13, 2011 16:02
-
-
Save a-bx/1472684 to your computer and use it in GitHub Desktop.
How to reset UIWebView's zoom
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
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