YYWebImage
YYWebImage copied to clipboard
清楚图片缓存锁死
[cache.diskCache removeAllObjectsWithProgressBlock:^(int removedCount, int totalCount) { // progress } endBlock:^(BOOL error) { if (!error) { YYImageCache *cache = [YYWebImageManager sharedManager].cache; cache.diskCache.totalCost; } }]; 这个方法清除缓存, 再获取totalCost,会失效,而且会出现卡死的情况
endBlock 在锁的内部,目前可以先在 endBlock 里再 dispatch 一次执行。稍后会修复。
@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 ,但是菊花还是没有停止。且走到下方重新获取缓存大小的那一行后就锁死了。。。没有任何办法操作。。
非得用你的方法清除缓存么? 自己写方法操作 直接锁死了!