I am trying to load the image(png) in UIWebview. But I got the following error ""ImageIO: PNGinvalid literal/lengths set"
I will get the "png" from the web service. I will store it in the following path. "Users/XXX/Library/Application Support/iPhone Simulator/4.3.2/Applications/E4DE3097-EA84-492F-A2A7-5882202F3B00/Documents/attachement.png "
When I reading the file from the path, I got the error. I am using the following code
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];
Please help me.
THanks Girija
If you have saved the Image in Documents Folder, why are you fetching from MainBundle. Fetching Image from the Documents Directory would be :
NSString *aDocumentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *aFilePath = [NSString stringWithFormat:@"%@/attachement.png", aDocumentsDirectory];
UIImage *anImage = [UIImage imageWithContentsOfFile:aFilePath];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.