在SDWebImage三方库里面有一个SDImageCache.h头文件,在这个里面有一个方法是clearDisk方法,用来清除缓存的.
//弹出框 确定是否清除缓存
- (void)alertView{
//计算SDImage 里面的缓存
float tmpSize=[[SDImageCache sharedImageCache] getSize] / 1024.0;
UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"提示" message:[NSString stringWithFormat:@"清理缓存(%.2fkb)",tmpSize] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[SDImageCache sharedImageCache] clearDisk];
[self.tableView reloadData];
}];
UIAlertAction *cancle=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:ok];
[alert addAction:cancle];
[self presentViewController:alert animated:YES completion:nil];
}