Created
February 19, 2011 07:31
-
-
Save choonkeat/834907 to your computer and use it in GitHub Desktop.
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)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { | |
CGFloat ratioAspect = webview.bounds.size.width/webview.bounds.size.height; | |
switch (toInterfaceOrientation) { | |
case UIInterfaceOrientationPortraitUpsideDown: | |
case UIInterfaceOrientationPortrait: | |
// Going to Portrait mode | |
for (UIScrollView *scroll in [webview subviews]) { //we get the scrollview | |
// Make sure it really is a scroll view and reset the zoom scale. | |
if ([scroll respondsToSelector:@selector(setZoomScale:)]){ | |
scroll.minimumZoomScale = scroll.minimumZoomScale/ratioAspect; | |
scroll.maximumZoomScale = scroll.maximumZoomScale/ratioAspect; | |
[scroll setZoomScale:(scroll.zoomScale/ratioAspect) animated:YES]; | |
} | |
} | |
break; | |
default: | |
// Going to Landscape mode | |
for (UIScrollView *scroll in [webview subviews]) { //we get the scrollview | |
// Make sure it really is a scroll view and reset the zoom scale. | |
if ([scroll respondsToSelector:@selector(setZoomScale:)]){ | |
scroll.minimumZoomScale = scroll.minimumZoomScale *ratioAspect; | |
scroll.maximumZoomScale = scroll.maximumZoomScale *ratioAspect; | |
[scroll setZoomScale:(scroll.zoomScale*ratioAspect) animated:YES]; | |
} | |
} | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment