美文网首页
获取webview的内容高度

获取webview的内容高度

作者: 赤焰军少帅林殊 | 来源:发表于2018-05-21 18:34 被阅读21次
    NSString *htmlHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"];
    //HTML5的宽度
    NSString *htmlWidth = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollWidth"];
    //宽高比
    float i = [htmlWidth floatValue]/[htmlHeight floatValue];
    
    //webview控件的最终高度
    float height = SCREEN_WIDTH/i;
    
    self.cellheight=height;
    self.webView.frame=CGRectMake(0, 0, SCREEN_WIDTH, self.cellheight);
    [self.tableView reloadData];

相关文章

网友评论

      本文标题:获取webview的内容高度

      本文链接:https://www.haomeiwen.com/subject/bwyqjftx.html