我知道如何在WebView中加载图像,现在我试图在HTML中嵌入图像并加载到UIWebView中。 下列是我使用的代码,在Html中嵌入图像并在UIWebView中加载
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectoryPath = [paths objectAtIndex:0];
NSString* folderPath = [documentsDirectoryPath stringByAppendingPathComponent:@"iOSDevices"];
NSArray* filesCount = [[NSFileManager defaultManager ] folderPath error:nil];
NSString* path = [NSString stringWithFormat:@"%@/%@",folderPath,[filesCount objectAtIndex:0]];
NSString *htmlString = [NSString stringWithFormat:@"<html><body><img src=\"%@\" type=\"jpg\" width=\"320\" height=\"480\"></body></html>", path];
[_webView loadHTMLString:htmlString baseURL:nil];
我缺少的东西?
我试过了。 @“
”。不工作 – Cyril我也尝试过。 @“
”。在哪里page01.jpg存储 – NANNAV工作正常:)。添加名称并设置基本网址使其工作 – Cyril