// 图视频
[self.mainWeb loadHTMLString:[self reSizeVideoWithHTMLHadHead] baseURL:nil];
// 图文
[self.mainWeb loadHTMLString:[self reSizeImageWithHTMLHadHead] baseURL:nil];
/// 注入 视频
- (NSString *)reSizeVideoWithHTMLHadHead
{
NSString *urlStr1 = [NSString stringWithFormat:@"<video src='%@' controls='controls' width = '400' height = '300'>您的浏览器不支持 video 标签。</video> %@", <#你的视频地址.mp4#>, <#你的html#>];
return urlStr1;
}
/// 注入 图片
- (NSString *)reSizeImageWithHTMLHadHead
{
NSString *urlStr1 = [NSString stringWithFormat:@"<img src='%@' /><br/> %@", <#你的图片地址.png#>, <#你的html#>];
NSString *content = [urlStr1 stringByReplacingOccurrencesOfString:@"&quot" withString:@"'"];
content = [content stringByReplacingOccurrencesOfString:@"<" withString:@"<"];
content = [content stringByReplacingOccurrencesOfString:@">" withString:@">"];
content = [content stringByReplacingOccurrencesOfString:@""" withString:@"\""];
NSString *htmls = [NSString stringWithFormat:@"<html> \n"
"<head> \n"
"<meta name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" /> \n"
"<style type=\"text/css\"> \n"
"body {font-size:15px;}\n"
"</style> \n"
"</head> \n"
"<body>"
"<script type='text/javascript'>"
"window.onload = function(){\n"
"var $img = document.getElementsByTagName('img');\n"
"for(var p in $img){\n"
"$img[p].style.width = '100%%';\n"
"$img[p].style.height = 'auto'\n"
"}\n"
"}"
"</script>%@"
"</body>"
"</html>", content];
return htmls;
}