使用SDWebImage清除图片缓存
来源:互联网 发布:越南新娘价格淘宝图片 编辑:程序博客网 时间:2024/04/29 00:33
使用下面清除缓存的方法需要导入#import "SDImageCache.h"
//清除缓存的点击方法
- (void)clearBtnClicked:(UIButton *)sender
{
NSString *caches = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
//调用清除方法
[self clearCache:caches];
}
//清除缓存文件
- (void)clearCache:(NSString *)path{NSFileManager *fileManager=[NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:path]) {
NSArray *childerFiles=[fileManager subpathsAtPath:path];
for (NSString *fileName in childerFiles) {
//如有需要,加入条件,过滤掉不想删除的文件
NSString *absolutePath=[path stringByAppendingPathComponent:fileName];
[fileManager removeItemAtPath:absolutePath error:nil];
}
}
[[SDImageCache sharedImageCache] cleanDisk];
}
- (long long)fileSizeAtPath:(NSString *)filePath{
NSFileManager* manager = [NSFileManager defaultManager];
if ([manager fileExistsAtPath:filePath]){
return [[manager attributesOfItemAtPath:filePath error:nil] fileSize];
}
return 0;
}
//遍历文件夹获得文件夹大小,返回多少M
- (float)folderSizeAtPath:(NSString *)folderPath{
NSFileManager* manager = [NSFileManager defaultManager];
if (![manager fileExistsAtPath:folderPath]) return 0;
NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath:folderPath] objectEnumerator];
NSString* fileName;
long long folderSize = 0;
while ((fileName = [childFilesEnumerator nextObject]) != nil){
NSString* fileAbsolutePath = [folderPath stringByAppendingPathComponent:fileName];
folderSize += [self fileSizeAtPath:fileAbsolutePath];
}
return folderSize/(1024.0*1024.0);
}
1 0
- 使用SDWebImage清除图片缓存
- SDWebimage手动清除缓存图片
- 使用SDWebImage 清除App 缓存
- 使用SDWebimage 缓存图片
- SDWebImage框架清除内存中的缓存图片
- 【SDWebImage】 显示图片缓存大小和清除缓存
- SDWebImage使用——一个可管理远程图片加载的类库+ SDWebImage手动清除缓存的方法
- sdwebImage 如何清除缓存
- SDWebImage清除缓存
- sdwebimage清除缓存
- iOS SDwebimage清除缓存
- SDWebImage清除缓存方法
- SDWebImage清除某一特定url的图片缓存
- 《iOS开发笔记—SDWebImage图片缓存与清除》
- [绍棠] SDWebImage 手动清除缓存及SDWebImage缓存图片的机制
- SDWebImage 获取缓存,清除缓存
- SDWebImage框架,清除图片
- iOS图片缓存开源库SDWebImage的使用
- 清除WebSphere中jsp缓存
- 【Storm入门指南】第七章 在 Storm 中使用非 JVM 语言
- 【PHP】PHP7的异常处理详解
- Rcpp简明入门
- Retrofit+RxJava实战日志(2)-基本使用
- 使用SDWebImage清除图片缓存
- Hadoop中datanode无法启动
- javascript cookbook: modulization
- iOS方法类:CGAffineTransform的使用大概
- [译]【Storm入门指南】第八章 事务 Topologies
- Cocos2d-x Tutorial C++ 类到 Lua
- 生产者消费者例子-采用wait()和notify()
- android 根据Bitmap bitmap 保存图片到手机上
- iOS 7视图之间交互式过渡