iphone - 在 Html 中嵌入图像并在 UIWebView 中加载

标签 iphone html ios cocoa-touch uiwebview

我知道如何在 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/

相关文章:

ios - Xcode:错误:无法使用重复的目标启动。原始目标在 Xcode/gdb 中运行良好

c# - Xamarin.iOS 应用程序 (C#) 中的手指绘图

html - 为什么 IE7 在翻转时显示滚动条?

html - 如何轻松地垂直镜像我的 HTML?

mysql - 如何将数据从数据库传递到 Google Chart

iphone - 在 MacOS 上通过命令行连接到蓝牙设备 (iPhone)

ios - Sprite 套件 - Spring 接头(减震器)

android - 如何检测墙壁的长边以准备 mask 和重新着色

ios - 为什么在 iPhone 4、5、6 中横向压缩宽度和压缩高度

iPhone - 在矢量应用程序上创建 Quartz 路径?