没有缓存的UIWebview

没有缓存的UIWebview

问题描述:

我想加载没有缓存的webview?

I want to load a webview without cache?

//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Request Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[kdgWebView loadRequest:requestObj];


Objective-C:

Objective-C:

// Remove and disable all URL Cache, but doesn't seem to affect the memory
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];

您可以在 http://blog.techno-barje.fr/post/2010/10/04/ UIWebView-secrets-part2-leaks-on-release /

Swift:

URLCache.shared.removeAllCachedResponses()
URLCache.shared.diskCapacity = 0
URLCache.shared.memoryCapacity = 0