1

I have an image (png) in the app document directory, which is a screenshot of a UIView. The image will be saved when user clicked a UIButton. I use stringByEvaluatingJavaScriptFromString to inject the image into a div in a UIWebView. The problem is when the app loads first, the correct image it added, but in run time the image is not changed, it only shows the image which was in the directory when loading. I tried cleaning the cache and etc but no use.

note - the webview loads local html files - I use arc

How can I add the correct image from the documentry directory to the webview. ?

UPDATE it works fine on IOS 5.. issue is only on IOS 6..

4

3 回答 3

0

我猜你给的图像路径是这样/Users/file/...some other paths../Documents/Images/imag.png的。
您提供的图像路径在您的文件中应该是这样的HTML,因为您正在尝试从本地路径加载图像。file:///Users/file/...some other paths../Documents/Images/imag.png

于 2012-12-11T10:22:13.780 回答
0

我找不到这个问题背后的技术问题,但我通过每次保存图像文件时提供唯一名称来修复它。

    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    int timeInter = [[NSDate date]timeIntervalSince1970];
    [userDefaults setInteger:timeInter forKey:WHEEL_NUMBER];
    NSNumber *newWheelKey = [userDefaults valueForKey:WHEEL_NUMBER];

我用newWheelKey. 删除图像文件夹时viewdiddisappear

于 2012-12-12T08:12:29.910 回答
0

确保每次将图像保存在文档目录中时,您都必须提供不同的名称并根据图像进行检索。

于 2012-12-11T10:13:35.067 回答