iOS UIWebView加载html代码

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.com/staticimage?center=116.404,39.915&zoom=10&width=530&height=340&markers=116.404,39.915"/></section></section><p>&nbsp;</p>";
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值