UIWebView
和 MKWebview
添加缓存管理分类pod try DPWebViewLocalCache
来尝试示例Objective-C:
#import <DPLocalCache.h>
...
- (void)viewDidLoad {
//Any place to add only once!!!
//添加浏览器本地缓存处理
DPLocalCache *urlCache = [[DPLocalCache alloc] initWithMemoryCapacity:20 * 1024 * 1024
diskCapacity:200 * 1024 * 1024
diskPath:nil
cacheTime:60*60*24
modeTybe:DOWNLOAD_MODE
subDirectory:@"PXPT"];
[NSURLCache setSharedURLCache:urlCache];
}
- (void)didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
//Any place to add only once!!!
DPLocalCache *urlCache = (DPLocalCache *)[NSURLCache sharedURLCache];
[urlCache removeAllCachedResponses];
}
...
有三种方法可以在项目中使用 DPWebViewLocalCache:
platform :ios, '7.0'
pod 'DPWebViewLocalCache', '~> 1.1.6'
如果您正在使用Swift,请确保添加use_frameworks!
并设置目标为iOS 8+
platform :ios, '8.0'
use_frameworks!
此时,您的工作区应该可以无错误地构建。如果您遇到问题,请发布到问题区,社区可以帮助您解决问题。
所有源代码均受MIT许可证许可。