方向上的Web视图宽度问题

问题描述

| 我在方向更改时遇到了webView的问题,当方向从“纵向”更改为“横向”时,webview的宽度会增加。现在,当我将方向更改为纵向时,Web视图的宽度仍然与横向模式相同。它在页面和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;
    }
}
提前致谢 :)     

解决方法

        有关UIWebView的定向问题,请参见此线程。     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...