float tmpSize = [[SDImageCache sharedImageCache] getSize];
NSString *clearMessage = tmpSize >= 1024 * 1024 ? [NSString stringWithFormat:@"清理缓存(%.2fM)" , tmpSize / 1024 / 1024] : [NSString stringWithFormat:@"清理缓存(%.2fK)", tmpSize / 1024];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:clearMessage preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[SDImageCache sharedImageCache]clearDisk];
//清除内存缓存
[[[SDWebImageManager sharedManager] imageCache] clearMemory];
//清除系统缓存
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}];
[alert addAction:action2];
[alert addAction:action1];
[self presentViewController:alert animated:YES completion:nil];
网友评论