UIWebView在旋转时接管屏幕

我正在使用UIWebView和UIViewController创建横幅。在控制器中我设置了shouldAutorotateToInterfaceOrientation以始终返回YES。在loadView中,我创建了我的UIWebView并使用CGRectMake为它提供了一个小横幅框架。它被添加到屏幕后一切正常。屏幕旋转时会出现此问题。 UIWebView现在接管整个屏幕。如果我使用NSLog输出它的帧,我可以看到它被旋转覆盖以占据整个屏幕。知道如何让它停止这样做吗?我觉得我缺少一些基本的东西,但我无法弄清楚出了什么问题。     
已邀请:
如果您加载UIWebview,在旋转时您应该将UIWebview的宽度设置为480,这将在您加载的页面上声明一个javascript函数然后在委托上完成
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{


    if ((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
        (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight))
    {
            [webView stringByEvaluatingJavaScriptFromString:@"makeWidth(480)"]; 
    }else{
            [webView stringByEvaluatingJavaScriptFromString:@"makeWidth(320)"]; 
    }
注意makeWidth(480)是你加载的页面中的一个javascript函数,你应该在webview中声明该函数并从xcode调用它。     

要回复问题请先登录注册