美文网首页
cell嵌套webView,cell高度自动调整 一

cell嵌套webView,cell高度自动调整 一

作者: 大码猴 | 来源:发表于2018-12-05 16:53 被阅读13次

竟然自动执行了js。只能贴图

- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{

     return self.webView.frame.size.height;

}

- (UIWebView*)webView{

    if(!_webView) {

        _webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, Main_Screen_Width, 1)];

        _webView.delegate=self;

        _webView.scrollView.scrollEnabled = NO;

    }

    return _webView;

}

#pragma mark - UIWebView Delegate Methods

-(void)webViewDidFinishLoad:(UIWebView*)webView

{

    [MBProgressHUD hideHUDForView:self.VC.view animated:YES];

    //获取到webview的高度

    CGFloat height = [[self.webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] floatValue];

    self.webView.frame = CGRectMake(self.webView.frame.origin.x,self.webView.frame.origin.y, Main_Screen_Width, height);

    [self.detailTableView reloadData];

}

- (void)webViewDidStartLoad:(UIWebView*)webView

{

    NSLog(@"webViewDidStartLoad");

    [MBProgressHUD showHUDAddedTo:self.VC.view animated:YES];

}

- (void)webView:(UIWebView*)webView didFailLoadWithError:(NSError*)error;

{

    NSLog(@"didFailLoadWithError===%@", error);

     [MBProgressHUD hideHUDForView:self.VC.view animated:YES];

}

相关文章

网友评论

      本文标题:cell嵌套webView,cell高度自动调整 一

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