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)];
        
    }
  • 相关阅读:
    POI 给单元格添加批注
    Linux下Mysql的odbc配置(修改网上博文)
    Linux下mysql实现类似于Sqlser的Profiler的访问记录监听功能
    windows下部署icescrum
    sql server2008查询会话的Ip地址、用户登录名、登录机器名
    error while loading shared libraries的解決方法
    做个标记,指针的指针的应用
    微信架构(转)
    网络监控netstat(转)
    大话MVC模式
  • 原文地址:https://www.cnblogs.com/zhujin/p/6168825.html
Copyright © 2011-2022 走看看