zoukankan      html  css  js  c++  java
  • WKWebview 拼接tableview,获取web内容高度

    - (void)addWKWebView
    {
        _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.1)];
        [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_activityModel.shareLink]]];
        _webView.scrollView.scrollEnabled = NO;
        _webView.UIDelegate = self;
        _webView.navigationDelegate = self;
        [_tableView setTableHeaderView:_webView];
        [SVProgressHUD show];
    }
    
    - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
    {
        [webView evaluateJavaScript:@"document.getElementById("content").offsetHeight"
                  completionHandler:^(id _Nullable result,NSError * _Nullable error) {
    //        获取页面高度,并重置webview的frame
            _webViewHeight = [result doubleValue];
            CGRect frame = webView.frame;
            frame.size.height = _webViewHeight;
            webView.frame = frame;
            [_tableView beginUpdates];
            [_tableView setTableHeaderView:_webView];
            [_tableView endUpdates];
            [self getActivityComments];
        }];
    }
    
    - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation{
        
    }
    
    - (void)addTableView
    {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT-64- 40) style:UITableViewStylePlain];
        
        [_tableView setBackgroundColor:[UIColor clearColor]];
        [_tableView setDelegate:self];
        [_tableView setDataSource:self];
        _tableView.tableFooterView = [UIView new];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        _tableView.separatorColor = SEPARATOR_COLOR_SYSTEM;
        [self.view addSubview:_tableView];
        [self loadLoadMoreFooter:_tableView action:@selector(loadMoreData)];
        
    }
  • 相关阅读:
    mysql binlog日志
    安装源码包(这里主要写了redis,其他都一样的操作)
    hashMap异常:java.util.ConcurrentModificationException
    谷歌post url “net::ERR_INCOMPLETE_CHUNKED_ENCODING”
    itextpdf结合jfinal模版生成pdf文件
    springboot项目jar冲突问题解决
    map遍历
    el和jstl表达式问题==0的问题
    fastJSON 解析转换包含下划线属性的问题
    CentOS 7 64位
  • 原文地址:https://www.cnblogs.com/zhujin/p/6168825.html
Copyright © 2011-2022 走看看