I have a UIWebView that loads up some html. In it is an img tag, I am saving an image in the app documents folder and I want to display that image within the html, I do so 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]];
the imageBlob is an NSdata with the data for the image. the image is saved successfully and rest of the html loads up fine but the image is not displayed.
This works fine if I set the baseUrl of the UIwebView to point to the documents folder. But I don't want to do that because I want the baseURL to be [NSBundle mainBundle] resourcePath] to access some javascript files and css