Let me illustrate an approach. Consider this untested pseudo-code.
@implementation MyViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
CGSize contentSize = self.webView.scrollView.contentSize;
switch (orientation) {
case UIInterfaceOrientationPortrait:
contentSize.width = 320.0;
self.webView.scrollView.contentSize = contentSize;
return YES;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
contentSize.height = 568.0;
self.webView.scrollView.contentSize = contentSize;
return YES;
}
return NO;
}
@end
The idea here is that when the underlying scroll view's content size fits the screen dimensions scrolling should not be possible. This code reacts to orientation changes (when the device is turned) and adjusts the edge lengths to their respective screen dimensions.
One problem with this is that the device has to be turned at least once and after turning the phone in both directions, the contentSize
is locked at {320, 568}
. To get around this, consider this SO.