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

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

cell嵌套webView,cell高度自动调整 一_第1张图片

- (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高度自动调整 一)