繁体   English   中英

UIWebview-加载PNG图像-错误

[英]UIWebview - Loading PNG image - got error

我正在尝试在UIWebview中加载image(png)。 但是我收到以下错误““ ImageIO:PNGinvalidliteral / lengths set”

我将从网络服务中获取“ png”。 我将其存储在以下路径中。 “用户/ XXX /库/应用程序支持/ iPhone模拟器/4.3.2/Applications/E4DE3097-EA84-492F-A2A7-5882202F3B00/Documents/attachement.png”

当我从路径中读取文件时,出现错误。 我正在使用以下代码

  NSBundle *bundle = [NSBundle mainBundle]; 


  NSString *path = [bundle bundlePath];
    NSURL *baseURL = [NSURL fileURLWithPath:path];

    NSString *commentHtml = [NSString stringWithFormat:@"<img src=\"%@\"/>", documentEntity.path];
    NSString *html3 = [NSString stringWithFormat:@"<html><head/><body><div><b>COMMENTS:</b></div>%@</body></html>", commentHtml];
    [self.documentView loadHTMLString:html3 baseURL:baseURL];

请帮我。

谢谢吉里嘉

如果已将“图像”保存在“文档”文件夹中,为什么要从MainBundle中提取图像。 从文档目录中获取图像将是:

    NSString *aDocumentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSString *aFilePath = [NSString stringWithFormat:@"%@/attachement.png", aDocumentsDirectory];
    UIImage *anImage = [UIImage imageWithContentsOfFile:aFilePath];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM