Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在Html中嵌入图像并在UIWebView中加载_Iphone_Html_Ios_Cocoa Touch_Uiwebview - Fatal编程技术网

Iphone 在Html中嵌入图像并在UIWebView中加载

Iphone 在Html中嵌入图像并在UIWebView中加载,iphone,html,ios,cocoa-touch,uiwebview,Iphone,Html,Ios,Cocoa Touch,Uiwebview,我知道如何在WebView中加载图像,现在我正在尝试将图像嵌入html并加载到UIWebView中。 以下是我正在使用的代码 NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* documentsDirectoryPath = [paths objectAtIndex:0]; NSString* folderPath =

我知道如何在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];
NSArray*path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString*documentsDirectoryPath=[paths objectAtIndex:0];
NSString*folderPath=[documentsDirectoryPath stringByAppendingPathComponent:@“iOSDevices”];
NSArray*FileCount=[[NSFileManager defaultManager]文件夹路径错误:nil];
NSString*path=[NSString stringWithFormat:@“%@/%@”,folderPath[FileCount objectAtIndex:0]];
NSString*htmlString=[NSString stringWithFormat:@',path];
[_webviewloadhtmlstring:htmlString baseURL:nil];

我遗漏了什么吗?

图像名称不可用,路径仅获取图像路径,不在路径中提供图像,在标记中添加图像名称

图像名称不可用,路径仅获取图像路径,不在路径中提供图像,在标记中添加图像名称

如果您试图从本地加载图像,只需在src前面添加此
文件://
,类似于
NSString*htmlString=[nsstringstringwithformat:@',path]
NSString *htmlString = [NSString stringWithFormat:@"<html><body><img src=\"file://%@\" type=\"jpg\" width=\"320\" height=\"480\"></body></html>", path];
检查是否显示图像“jpg”或“png”,并检查是否在
img
标记中给出了正确的
type

html字符串应为,

如果您试图从本地加载图像,只需在src前面添加此
文件://
,如
NSString*htmlString=[NSString stringWithFormat:@',path]
NSString *htmlString = [NSString stringWithFormat:@"<html><body><img src=\"file://%@\" type=\"jpg\" width=\"320\" height=\"480\"></body></html>", path];
检查是否显示图像“jpg”或“png”,并检查是否在
img
标记中给出了正确的
type

html字符串应为,

我也试过了@"". 不行,我也试过了@"". 其中page01.jpg存储工作:)。添加名称并设置基本url使其工作,但它不适合屏幕:(.你知道如何提供100%宽度和100%高度吗?我尝试过了,但显示了一些警告。图像大小仅设置了浏览器大小,设置了web视图填充图像我也尝试过。@“。不工作我也尝试过。@“。其中page01.jpg storedWorking:)。添加名称并设置基本url使其正常工作,但它不适合屏幕:(.你知道如何指定100%宽度和100%高度吗?我尝试过了,它显示了一些警告。图像大小仅设置浏览器大小,设置web视图填充图像是否无法将宽度和高度设置为100%?可以,设置宽度=\“100%%\”,高度=\“100%%\”,我们必须给“%”以转义此字符“%”。嗨,西里尔,如果你发现我的答案有用,只需单击投票编号下方的勾号。实际上,首先是Nannav解决的html问题。我将为你的答案投票。但我想为你的两个答案都选择勾号。是否无法将宽度和高度设置为100%?可以,请给出宽度=\“100%%\”,高度=\“100%%\”,我们必须给“%”以转义此字符“%”嗨,西里尔,如果你发现我的答案有用,只需单击投票数下方的勾号。实际上,首先是Nannav解决的html问题。我将投票给你。但我想为你的两个答复选择勾号