国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

SDWebImage手動清除緩存的方法

2019-11-09 17:41:15
字體:
來源:轉載
供稿:網友

1.找到SDImageCache類

2.添加如下方法:

[objc] view plain copy- (float)checkTmpSize  {      float totalSize = 0;      NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:diskCachePath];      for (NSString *fileName in fileEnumerator)      {          NSString *filePath = [diskCachePath stringByAppendingPathComponent:fileName];            NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];            unsigned long long length = [attrs fileSize];            totalSize += length / 1024.0 / 1024.0;      }  //    NSLog(@"tmp size is %.2f",totalSize);        return totalSize;  }  

新版的SDImageCache類,已增加此方法

[objc] view plain copy[[SDImageCache sharedImageCache] getSize];  

3.在設置里這樣使用

[objc] view plain copy#PRagma 清理緩存圖片    - (void)clearTmpPics  {      [[SDImageCache sharedImageCache] clearDisk];    //    [[SDImageCache sharedImageCache] clearMemory];//可有可無        DLog(@"clear disk");            float tmpSize = [[SDImageCache sharedImageCache] checkTmpSize];        NSString *clearCacheName = tmpSize >= 1 ? [NSString stringWithFormat:@"清理緩存(%.2fM)",tmpSize] : [NSString stringWithFormat:@"清理緩存(%.2fK)",tmpSize * 1024];        [configDataArray replaceObjectAtIndex:2 withObject:clearCacheName];        [configTableView reloadData];  }  
上一篇:VC生命周期

下一篇:ReactNative添加廣告SDK

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 资阳市| 砀山县| 行唐县| 和田县| 云安县| 承德市| 西盟| 台中市| 太谷县| 无锡市| 永安市| 西宁市| 南召县| 武汉市| 织金县| 内丘县| 南江县| 大方县| 同心县| 万载县| 柳河县| 家居| 福建省| 杭锦后旗| 富锦市| 马公市| 临邑县| 清流县| 镇宁| 宜州市| 昭通市| 龙游县| 百色市| 镶黄旗| 汝阳县| 阜新市| 五指山市| 兰坪| 安平县| 西丰县| 新干县|