iOS UIWebView加载html代码

一、问题描述:
请求回来的接口字段中,有一段html格式的代码段,这边需求是用webView加载,而不是进行html解析,过滤。
二、UIWebView加载html代码
我们在项目中用到最多的是UIWebView加载链接或者本地html文件的。这边最后寻求了度娘,找到了最佳解决方案。
这边直接上代码: loadHTMLString:方法

    UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectMake(20, 150, ScreenWidth-20, 400)];
    webView.delegate = self;
    NSString *htmlString = model.Remark;//这是html格式的代码段
    [webView loadHTMLString:htmlString baseURL:nil];

html格式的代码段如下:

 Remark = "<section title="807,更新于2016-08-04 21:16" class="yead_editor yead-selected" id="m807" style="margin: 5px auto; font-family: 微软雅黑, 宋体; font-size: 14px; white-space: normal;"><section style="padding: 0px; border: 0px currentColor; border-image: none;"></section><section style="padding: 0px; border: 0px currentColor; border-image: none;"><br/></section><section style="padding: 0px; border: 0px currentColor; border-image: none;">s;flkjsakjfksajfkfs</section><section style="padding: 0px; border: 0px currentColor; border-image: none;"><img width="530" height="340" src="http://api.map.baidu/staticimage?center=116.404,39.915&zoom=10&width=530&height=340&markers=116.404,39.915"/></section></section><p>&nbsp;</p>";

更多推荐

iOS UIWebView加载html代码