Skip to content

清楚图片缓存锁死 #131

Open
Open
@WilltuCode

Description

@WilltuCode

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

Activity

ibireme

ibireme commented on Sep 1, 2016

@ibireme
Owner

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

EchoZuo

EchoZuo commented on Dec 15, 2016

@EchoZuo

@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 ,但是菊花还是没有停止。且走到下方重新获取缓存大小的那一行后就锁死了。。。没有任何办法操作。。

Jack-Rain

Jack-Rain commented on Mar 24, 2017

@Jack-Rain

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ibireme@Jack-Rain@EchoZuo@WilltuCode

        Issue actions

          清楚图片缓存锁死 · Issue #131 · ibireme/YYWebImage