发个广告:iOS开发两年了,一步步走来,从小白到大白,有自己的新的体验 关注公众号一起进步,有技术、工具分享
_detailWebView = [[UIWebViewalloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(view.frame)+35,KScreenWidth,KScreenHeight-64-290)];
_detailWebView.delegate = self;
//预先加载url
NSString *detailStr = self.model.questiondesc;
NSString *newUrll = [detailStrstringByReplacingOccurrencesOfString:@"/upimg"withString:@"http://"];
[_detailWebView loadHTMLString:newUrll baseURL:nil];
[self.viewaddSubview:self.detailWebView];
#pragma mark - UIWebView Delegate Methods
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
//获取到webview的高度
CGFloat height = [[self.webViewstringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"]floatValue];
self.webView.frame =CGRectMake(self.webView.frame.origin.x,self.webView.frame.origin.y,KScreenWidth, height+20);
}