YYWebImage icon indicating copy to clipboard operation
YYWebImage copied to clipboard

清楚图片缓存锁死

Open WilltuCode opened this issue 8 years ago • 3 comments

[cache.diskCache removeAllObjectsWithProgressBlock:^(int removedCount, int totalCount) { // progress } endBlock:^(BOOL error) { if (!error) { YYImageCache *cache = [YYWebImageManager sharedManager].cache; cache.diskCache.totalCost; } }]; 这个方法清除缓存, 再获取totalCost,会失效,而且会出现卡死的情况

WilltuCode avatar Aug 25 '16 10:08 WilltuCode

endBlock 在锁的内部,目前可以先在 endBlock 里再 dispatch 一次执行。稍后会修复。

ibireme avatar Sep 01 '16 16:09 ibireme

@ibireme 我貌似和他遇到了同样的问题,用的是最新的版本。。 请问这个锁死的问题解决了吗?

代码如下: `YYImageCache *cache = [YYWebImageManager sharedManager].cache; [cache.diskCache removeAllObjectsWithProgressBlock:^(int removedCount, int totalCount) { NSLog(@"%d, %d",removedCount, totalCount) } endBlock:^(BOOL error) { if (error) { [Utility showAlertWithString:@"清理缓存失败"]; }else{

    [self.loadingHUD dismiss];
    
    float tempCacheSize = [YYWebImageManager sharedManager].cache.diskCache.totalCost;
    if (tempCacheSize >= 1) {
        self.tempCacheSizeString = [NSString stringWithFormat:@"%.2fM", tempCacheSize / 1024 / 1204];
    }else{
        [self performSelector:@selector(showSuccessAlertWithArray:) withObject:@[[UIApplication sharedApplication].keyWindow.rootViewController.view, @"清理完成"] afterDelay:1.0f];
        
        self.tempCacheSizeString = [NSString stringWithFormat:@"0M"];
        [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:3]] withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}

}];`

loadingHUD是一个菊花样式,我想的是在endblock中结束菊花。但是现在的问题是, 进入endblock之后,走过了dismiss ,但是菊花还是没有停止。且走到下方重新获取缓存大小的那一行后就锁死了。。。没有任何办法操作。。

EchoZuo avatar Dec 15 '16 09:12 EchoZuo

非得用你的方法清除缓存么? 自己写方法操作 直接锁死了!

Jack-Rain avatar Mar 24 '17 02:03 Jack-Rain