0
这里是我的代码来加载一个HTML文件,现在在html我想加载图像动态。UIWebView从本地加载html,但从远程使用web服务调用图像
NSString *path = [[NSBundle mainBundle] pathForResource:@"Myfile" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:path];
NSString *resourceURL = [[NSBundle mainBundle] resourcePath];
resourceURL = [resourceURL stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
resourceURL = [resourceURL stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSURL *baseURL = [NSURL URLWithString:[NSString stringWithFormat:@"file:/%@//",resourceURL]];
[self.webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];
这就是我的html的样子。在这里,而不是image.png我想使用web服务调用来填充图像。
<html>
<body>
<img src="image.png" />
</body>
</html>
另外我想用SDWebImage
来缓存图片。