IOS中对webView页面添加 缓存。
来源:互联网 发布:网络教育环境的组成 编辑:程序博客网 时间:2024/06/04 10:00
if (_webView) {
NSString *urlAddress = [_urlabsoluteString];
NSURL *url = [NSURLURLWithString:urlAddress];
NSURLRequest *request = [NSURLRequestrequestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoadtimeoutInterval: 10.0];
[_webViewloadRequest:request];
NSData *data0 = [NSURLConnectionsendSynchronousRequest:
[NSURLRequestrequestWithURL:url]
returningResponse:nil
error:nil];
//调用EGO
[[EGOCacheglobalCache] setData:data0forKey:@"webCache"];
}
-(void)loadPage:(NSString *)urlAddress {
NSURL *url = [NSURLURLWithString:urlAddress];
NSString* cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES)objectAtIndex:0];
NSString* file = [cachePathstringByAppendingPathComponent:@"/xxx.APPNAME/EGOCache/EGOCache.plist"];
NSDictionary *dict =[NSDictionarydictionaryWithContentsOfFile:file];
if ([dict objectForKey:urlAddress] )
{
// NSData *data = [[EGOCache globalCache] dataForKey:urlAddress];
// data = [NSURLConnection sendSynchronousRequest:
// [NSURLRequest requestWithURL:url]
// returningResponse:nil
// error:nil];
// NSLog(@"loading from cache %@",urlAddress);
}else{
NSData *data = [NSURLConnectionsendSynchronousRequest:
[NSURLRequestrequestWithURL:url]
returningResponse:nil
error:nil];
[[EGOCacheglobalCache] setData:dataforKey:urlAddress];
NSLog(@"saving cache %@",urlAddress);
[[EGOCacheglobalCache] setDefaultTimeoutInterval:60*60*24*4];//timeout (4 days)
}
NSURLRequest *request = [NSURLRequestrequestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoadtimeoutInterval: 10.0];
[_webViewloadRequest:request];
}
- IOS中对webView页面添加 缓存。
- [iOS开发] 加载webView页面添加POST请求
- ios webview清除缓存。
- ios webview清除缓存
- ios webview清除缓存
- ios webview清除缓存
- ios webview清除缓存
- iOS webview清除缓存
- iOS-清除webview缓存
- webview页面缓存处理机制
- iOS WebView中对Url中包含中文的解码
- 页面添加缓存
- 页面添加缓存-ehcache
- ios webview清除缓存Cookie
- iOS清除WebView的缓存
- iOS清除WebView的缓存
- iOS 清楚WebView的缓存
- iOS中给webView添加手势返回的问题
- java 对数值的处理
- 老板问:多长时间搞定?开发说3天,测试说2天,然后……
- 【UIkit】-8-UIActionSheet - 底部弹出提示,快要被取代
- uva 705 Slash Maze 斜线迷宫
- redis file mapping
- IOS中对webView页面添加 缓存。
- Codeforces 558E 线段树处理字符串内排序
- 如何将a、b的值进行交换,并且不使用任何中间变量?
- git的用法
- 【图论】2015 Multi-University Training Contest 1 1007
- java基础第九天
- Go语言中的多维数组传递
- 2015年ALPC暑期专题练习I (计算几何) J Kadj Squares
- MD5文件校验