【发布时间】:2011-09-05 08:04:01
【问题描述】:
我在改变方向时遇到了 webView 的问题,当方向从纵向变为横向时,webview 的宽度会增加。现在,当我将方向更改为纵向时,webviews 的宽度仍然与横向模式相同。它在页面右侧添加了额外的黑色空间,webview 允许向其滚动。有什么方法可以最小化纵向模式下 webview 的滚动宽度。
我正在使用以下代码来支持网页的方向。
- (void)webViewDidFinishLoad:(UIWebView *)webView {
NSLog(@"\nwebViewDidFinishLoad\n");
switch (self.interfaceOrientation)
{
case UIDeviceOrientationPortrait:
[self.webView stringByEvaluatingJavaScriptFromString:@"window.__defineGetter__('orientation',function(){return 0;});window.onorientationchange();"];
NSLog(@"\nUIDeviceOrientationPortrait\n");
break;
case UIDeviceOrientationLandscapeLeft:
[self.webView stringByEvaluatingJavaScriptFromString:@"window.__defineGetter__('orientation',function(){return 90;});window.onorientationchange();"];
NSLog(@"\nUIDeviceOrientationLandscapeLeft\n");
break;
case UIDeviceOrientationLandscapeRight:
[self.webView stringByEvaluatingJavaScriptFromString:@"window.__defineGetter__('orientation',function(){return -90;});window.onorientationchange();"];
NSLog(@"\nUIDeviceOrientationLandscapeRight\n");
break;
case UIDeviceOrientationPortraitUpsideDown:
[self.webView stringByEvaluatingJavaScriptFromString:@"window.__defineGetter__('orientation',function(){return 180;});window.onorientationchange();"];
NSLog(@"\nUIDeviceOrientationPortraitUpsideDown\n");
break;
default:
break;
}
}
提前谢谢:)
【问题讨论】:
标签: iphone objective-c uiwebview