如何在ipad中清除webview缓存 [英] how to clear webview cache in ipad
本文介绍了如何在ipad中清除webview缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里我使用
加载uiwebview中的内容 [webView loadHTMLString:[theApp.contentArr objectAtIndex:spineIndex] baseURL :URL]返回后我需要清除缓存<$ p $
这里我尝试了这些方法来清除缓存:
[webView stringByEvaluatingJavaScriptFromString:@document。 body.innerHTML = \\;];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@about:blank]]];
//删除所有缓存的响应
[[NSURLCache sharedURLCache] removeAllCachedResponses];
//设置空缓存
NSURLCache * sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
但没有用,这是什么解决方案......
解决方案使用 -
[webView stringByEvaluatingJavaScriptFromString:@ document.body.innerHTML = \\;];
NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@about:blank]];
[urlRequest setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[webView loadRequest:urlRequest];
Here i have load the content in the uiwebview using
[webView loadHTMLString:[theApp.contentArr objectAtIndex:spineIndex] baseURL:url];
after going back and come i need to clear the cache
here i have tried these kinds of methods to clear the cache:
[webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML = \"\";"];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
// remove all cached responses
[[NSURLCache sharedURLCache] removeAllCachedResponses];
// set an empty cache
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
but no use, what is the solution for this.....
解决方案 Use -
[webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML = \"\";"];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]];
[urlRequest setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[webView loadRequest:urlRequest];
这篇关于如何在ipad中清除webview缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文