我知道如何在 WebView 中加载图像,现在我正在尝试在 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];
我错过了什么吗?
最佳答案
图片名称不可用,path只能获取图片路径,不能在路径中给出图片,在标签中添加图片名称
关于iphone - 在 Html 中嵌入图像并在 UIWebView 中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13703002/