UIWebView如何清除缓存

编程入门 行业动态 更新时间:2024-10-22 08:30:49
本文介绍了UIWebView如何清除缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何清除UIWebView的缓存?

How to clear the cache of a UIWebView?

我正在制作一个简单的应用程序(只有三个按钮(后退,前进,刷新)和一个UIWebView)和我意识到在我的文件和数据iPhone获得了非常高的Cache值。我已经查看了各种文档和帖子(甚至在StackOverflow这里),但没有解决问题。 如果您需要代码行,请询问。

I am making a simple application (with only three buttons (back, forward, refresh) and a UIWebView) and I realized that in my Documents & Data iPhone gets a very high value of Cache. I already looked at various documents and posts (even here at StackOverflow) but none solved the problem. If you need lines of codes, ask.

推荐答案

[[NSURLCache sharedURLCache] removeCachedResponseForRequest:NSURLRequest];

这将删除特定请求的缓存响应。还有一个调用将删除在UIWebView上运行的所有请求的所有缓存响应:

This would remove a cached response for a specific request. There is also a call that will remove all cached responses for all requests ran on the UIWebView:

[[NSURLCache sharedURLCache] removeAllCachedResponses];

之后,您可以尝试使用UIWebView删除任何关联的cookie:

After that, you can try deleting any associated cookies with the UIWebView:

for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) { if([[cookie domain] isEqualToString:someNSStringUrlDomain]) { [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie]; } }

更多推荐

UIWebView如何清除缓存

本文发布于:2023-11-26 03:03:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632379.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   UIWebView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!