code4app里面的代码。。
核心代码。。。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
CustomURLCache *urlCache = [[CustomURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024
diskCapacity:200 * 1024 * 1024
diskPath:nil
cacheTime:0];
[CustomURLCache setSharedURLCache:urlCache];
}
returnself;
}
ios8,添加到我的项目中,这个方法有点问题。。。。需要用gitHub里面的一个demo才可以。。。
https://github.com/rnapier/RNCachingURLProtocol
在进入webVIew页面的时候。。。。。
[NSURLProtocolunregisterClass:[RNCachingURLProtocolclass]];///开启自定义的webview缓存方法。
离开webVIew的时候。。。
[NSURLProtocolregisterClass:[RNCachingURLProtocolclass]];///开启自定义的webview缓存方法。
其他都不需要做,,,只要引入相关文件就可以了。。。。
下面是demo。。。。