我的UIWebView在iOS中没有完全加载URL?

时间:2014-09-25 14:49:03

标签: ios ios7 uiwebview uiwebviewdelegate

我正在开发一个iPhone应用程序,我正在打开一个UIWebView的URL。问题是URL没有完美加载。根据我的要求,我需要添加UIWebView作为我的表的页脚视图。但问题是从webViewDidFinishLoad方法获取Web视图内容高度大小后,我正在设置页脚视图的框架。这是我的代码:

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

        aWebView.scrollView.scrollEnabled = NO;
        CGRect frame = aWebView.frame;
        frame.size.height = 1;
        aWebView.frame = frame;
        CGSize fittingSize = [aWebView sizeThatFits:CGSizeZero];
        frame.size = fittingSize;
        aWebView.frame = frame;

        [self setFooterView:fittingSize.height + aWebView.frame.origin.y];
}

-(void)setFooterView:(float)fittingHeight
{
    bottomView.frame = CGRectMake(0, 0, 320, fittingHeight);
    webViewSocial.frame = bottomView.frame;
    [tableView reloadData];
}

但是当我滚动我的表视图时,我的UIWebView(页脚视图)不会完全滚动。你能告诉我如何实现我的输出。谢谢!

1 个答案:

答案 0 :(得分:1)

尝试像这样设置

- (void)webViewDidFinishLoad:(UIWebView *)aWebView {
       CGFloat height = [[self.webView stringByEvaluatingJavaScriptFromString:@"document.height"] floatValue];
       CGFloat width = [[self.webView stringByEvaluatingJavaScriptFromString:@"document.width"] floatValue];
       CGRect frame = self.webView.frame;
       frame.size.height = height;
       frame.size.width = width;
       self.webView.frame = frame;
       self.tableView.tableFooterView = webView;
}