iOS中旋转后的UIWebview文档高度

iOS中旋转后的UIWebview文档高度,ios,uiwebview,height,document,Ios,Uiwebview,Height,Document,我有一个UIWebView,我在webViewDidFinishLoad事件上获得文档高度,如下所示: -(void)webViewDidFinishLoad:(UIWebView *)aWebView { heightWebView = [[aWebView stringByEvaluatingJavaScriptFromString:@"document.height"] floatValue]; NSLog(@"webview height: %f", heightWeb

我有一个UIWebView,我在webViewDidFinishLoad事件上获得文档高度,如下所示:

-(void)webViewDidFinishLoad:(UIWebView *)aWebView {

    heightWebView = [[aWebView stringByEvaluatingJavaScriptFromString:@"document.height"] floatValue];
    NSLog(@"webview height: %f", heightWebView);

}
didRotateFromInterfaceOrientation
事件中,我正在重新加载webView html字符串。我不知道为什么在横向模式和纵向模式下获得相同的文档高度


有什么解决方案吗?

您需要更改纵向和横向的框架

借助于CGRectMake方法

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{

    [_ScrollView setContentSize:CGSizeMake(320, 470)];
    if(toInterfaceOrientation == UIDeviceOrientationPortrait){
        [_btnBooks setFrame:CGRectMake(116, 29, 86, 88)];
    }
    else
    {
        if (IPHONE5) {
            [_btnBooks setFrame:CGRectMake(240, 29, 86, 88)];
        }
        else
        {

            [_btnBooks setFrame:CGRectMake(196, 29, 86, 88)];
        }
    }
}
试试这个-