【问题标题】:Web view width issue on orientation方向上的 Web 视图宽度问题
【发布时间】: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


    【解决方案1】:

    有关 UIWebView 的方向问题,请参阅此线程...Thread

    【讨论】:

      猜你喜欢
      • 2011-07-01
      • 1970-01-01
      • 2012-01-07
      • 1970-01-01
      • 2019-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-28
      相关资源
      最近更新 更多