UIWebView *webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, WIDTH,describeHeight)];
webView.scalesPageToFit=YES;
webView.delegate=self;
webView.scrollView.scrollEnabled=NO;
二:webView请求数据的方法有两种:
1):请求html格式的连接
NSString *html=[Manager stringIsEmpty:detailDic[@"tpDesp"]];
[webView loadHTMLString:html baseURL:nil];
2):请求url
NSString *string = dic[@"tpDesp"];
NSURL *url =[NSURL URLWithString:[NSString stringWithFormat:@"%@",string]];
NSURLRequest *request =[NSURLRequest requestWithURL:url];
[webView loadRequest:request];
三:可以使图片充满屏幕(以下代码是针对jgp格式的图片,如果是png格式的,直接将下面字符串style中的.jpg换成.png即可)
NSString *html=self.htmlStr;
NSString *style=@".jpg\" style=\"width:100%;\"";
NSArray *arr=[html componentsSeparatedByString:@".jpg\""];
NSMutableArray *webStrArr=[NSMutableArray arrayWithArray:arr];
NSString *webUrl=[webStrArr componentsJoinedByString:style];
[webView loadHTMLString:webUrl baseURL:nil];
四: 设置字体的大小
- (void)webViewDidFinishLoad:(UIWebView *)webView{
NSString *str = @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '250%'";
[_webView stringByEvaluatingJavaScriptFromString:str];
}