zoukankan      html  css  js  c++  java
  • 获得WebView的高度 iOS

    -(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
    {
        [webView evaluateJavaScript:@"document.body.scrollWidth"completionHandler:^(id _Nullable result,NSError * _Nullable error){
            CGFloat ratio =  CGRectGetWidth(webView.frame) /[result floatValue];
            //如果scrollHeight方法有问题 可以找webview商议获得lastLinediv试试
    //        NSString *meta = @"document.getElementById("lastLinediv").offsetTop";
            NSString *meta = @"document.body.scrollHeight";
            [webView evaluateJavaScript:meta completionHandler:^(id _Nullable result,NSError * _Nullable error){
                //webview的高度
                CGFloat newHeight = [result floatValue]*ratio;
                
            }];
        }];
    }
    在北京的灯中,有一盏是我家的。这个梦何时可以实现?哪怕微微亮。北京就像魔鬼训练营,有能力的留,没能力的走……
  • 相关阅读:
    <LinkedList> 61
    <LinkedList> (hard + 高)25
    <DP> (高频)322
    <BackTracking> (dfs hard) 291
    <Tree> (高频)236
    <Math> 29 365
    <String> 161 358
    <Array> 309 (高)334
    <Array> 54 (高频+hard )45
    <Design> 359 346
  • 原文地址:https://www.cnblogs.com/huangzs/p/15237447.html
Copyright © 2011-2022 走看看