objective-c - 如何清除ipad中的webview缓存

标签 objective-c ios ipad uiwebview

在这里,我使用

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

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

最佳答案

简单的方法:

NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];

关于objective-c - 如何清除ipad中的webview缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10686748/

相关文章:

ipad - 当键盘出现在带有 iOS8 的 iPad 上时,将模态呈现的 UIViewController 向上移动

objective-c - 在检查类型之前将 id 存储到真正的类指针中是否安全

iphone - 读取崩溃日志并将其发送到服务器

objective-c - EXC_BAD_ACCESS问题与发布声明

ios - 如何以编程方式绕过 iOS 中的代理?

ios - SpriteKit iPhone/iPad 不同的分辨率,需要相同的物理

ios - 更新 iPhone 应用程序删除了旧版本数据

ios - 如何居中对齐 iphone 的最大视口(viewport)缩放

iphone - 在应用程序购买中,SKPaymentTransactionStatePurchased 重试

ios - 如何在objective-c中声明C数组属性