1.后台返回一部分html的字符串回来的时候,如:
NSString *htmlStr =@"内容省略<div>内容省略2
<div>内容省略3
<div>电话:12222211111<span class="Apple-tab-span" style="white-space:pre">\t</span></div></div></div>";
如果不想以截字符串的形式,简单快捷的话,可以用webView的方式去接收,具体:
[self.contentWebView loadHTMLString:htmlStr baseURL:nil];
不过这样也存在高度适配的问题,所以搭配 UIWebView的delegate来用
- (void)webViewDidFinishLoad:(UIWebView *)webView{
float height = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"] floatValue];
NSLog(@"____%f",height);
//拿到高度后更新一下
[self.contentWebView setYh_height:(height + 3)];
[self updateHeaderViewSite];
}
网友评论