2015-05-15 125 views
0

我已經通過各種解決方案來清除UIWebView中的本地圖像緩存,而我試圖在HTML中加載圖像它原子地顯示以前的圖像(我使用相同的名稱來替換圖像模板)。UIWebView中的本地HTML緩存策略

[[NSURLCache sharedURLCache] removeAllCachedResponses]; 
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL fileURLWithPath:[[CustomFunctions getFilesPath] stringByAppendingPathComponent:obj]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0]; 
[webview1 loadRequest:request]; 
[webview1 reload]; 

這是我的代碼,可以任何人請建議我這樣做。提前致謝。對不起我的英語不好。

回答

0

//防止網頁的內部緩存中的應用

NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; 
[NSURLCache setSharedURLCache:sharedCache]; 
//[sharedCache release]; 
sharedCache = nil; 

嘗試使用此。它會清除應用程序的url緩存內存。

+0

沒有任何效果。在html中仍然有相同的圖像。 – Gowtham

+0

使您的webview n並再次初始化它。 – aBilal17

0

嘗試......

[[NSURLCache sharedURLCache] removeCachedResponseForRequest:NSURLRequest]; 

這將刪除特定請求的緩存響應。還有一個調用會刪除在UIWebView上運行的所有請求的緩存響應:

[[NSURLCache sharedURLCache] removeAllCachedResponses]; 
+0

@iOSCreator我發佈了我的答案,請檢查它。 –

+0

沒有工作。仍然有相同的圖像。 – Gowtham