这不是处理这种情况的正确方法。而不是在图像视图中加载图像并且必须始终牢记高度和宽度以及所有这些东西......最简单和最可靠的解决方案就是将图像加载到 html 字符串中,就是这样!只要确保 baseURL 如此,无论您采取什么方向,一切都会好起来的:
NSString* extension = @"gif";
NSString* strRR = [NSString stringWithFormat:@"%@.%@", authorNAme2,extension];
NSString *path = [[NSBundle mainBundle] bundlePath];
//NSLog(@"This is the path %@", path);
NSURL *baseURL = [NSURL fileURLWithPath:path];
// NSLog(@"this is the base URL %@",baseURL);
NSString *cachePath = [NSString stringWithFormat:@"%@/%@", path,strRR];
NSString * htmlString = [NSString stringWithFormat:@"\
<html>\
<table width='100%%'>\<tr>\<td>\
<body>\
<p style = 'font-size:30px;'> %@ <\p>\
</td></tr><tr><td><br></td></tr><tr><td align ='center'><br><img src='%@' width='60%%' \></td></tr></body>\
</table>\
</html>",authorNAme , cachePath];
// NSString *selection = [WebV2 stringByEvaluatingJavaScriptFromString:@"window.getSelection().toString()"];
// NSLog(@"*/*/*/*/**/*/*/*/*/*/*//*/ This is your selection mate %@" , selection);
WebV.opaque = NO;
WebV.backgroundColor = [UIColor clearColor];
[self.WebV setScalesPageToFit:YES];
[self.WebV loadHTMLString:htmlString baseURL:baseURL];