首页 > 移动平台 > 详细

iOS webview 清除缓存

时间:2018-03-10 21:31:52      阅读:255      评论:0      收藏:0      [点我收藏+]

使用iOS的UIWebview会自动进行缓存,我们在开发的时候要记得清除Cookie和缓存。

_webView = nil;

[self cleanCacheAndCookie];

调用的方法代码如下:

/**清除缓存和cookie*/

- (void)cleanCacheAndCookie{

//清除cookies

NSHTTPCookie *cookie;

NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];

for (cookie in [storage cookies]){

[storage deleteCookie:cookie];

}

//清除UIWebView的缓存

NSURLCache * cache = [NSURLCache sharedURLCache];

[cache removeAllCachedResponses];

[cache setDiskCapacity:0];

[cache setMemoryCapacity:0];

}

iOS webview 清除缓存

原文:https://www.cnblogs.com/linusflow/p/8541899.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!