我面临着关于方向更改的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;
}
}
提前致谢:)