I have a UIWebView that loads some html. It has an img tag in it, I save the image in the application's document folder, and I want to display this image in html, I do it like this.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES); NSString *documentsDir = [paths objectAtIndex:0]; NSString *tempImgFN = [NSString stringWithFormat:@"tempImg%d.jpg",storyRowID]; NSString *tempImg = [documentsDir stringByAppendingPathComponent:tempImgFN]; [imageBlob writeToFile:tempImg atomically:NO]; tempImg = [tempImg stringByReplacingOccurrencesOfString:@"/" withString:@"//"]; tempImg = [tempImg stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; [string appendString:[NSString stringWithFormat:@"<img style='max-width:120px' src=\"%@\" alt=\"\"/>",tempImg]];
imageBlob is an NSdata with data for the image. the image will be saved successfully, and the rest of the html will load normally, but the image will not be displayed.
This works fine if I set baseUrl to a UIwebView to specify a document folder. But I don't want to do this because I want baseURL to be [NSBundle mainBundle] resourcePath] to access some javascript and css files
source share