0

在这里,我使用加载了 uiwebview 中的内容

[webView loadHTMLString:[theApp.contentArr objectAtIndex:spineIndex] baseURL:url];

回去之后我需要清除缓存

在这里,我尝试了这些方法来清除缓存:

 [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];

但是没用,有什么办法解决这个问题.....

4

2 回答 2

2

简单的方法 :

NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
于 2012-05-21T14:14:10.360 回答
2

利用 -

[webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML = \"\";"];

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]];
[urlRequest setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];

[webView loadRequest:urlRequest];
于 2012-05-21T14:16:17.353 回答