新版的SDWebImage 已经计算好文件大小 只需要调用清理就够了
//获取缓存文件大小
float tmpSize = [[SDImageCache sharedImageCache] getSize];
NSString *clearCacheName = [NSString stringWithFormat:@"确定清理缓存(%.2fM)?",tmpSize/1024/1024];
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:clearCacheName delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alertView setTag:1001];
[alertView show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView.tag == 1001) {
if (buttonIndex == 1) {
[[SDImageCache sharedImageCache] clearDisk];
}
}
}
/*
注意 是clearDisk 不是cleanDisk
*/
时间: 2024-10-06 02:47:07