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];
iOS 清除缓存(笔记)
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 初识OC,对封装简直一窍不通,只能先从简单的控件开始学起,下面是封装的一个UIAlertViewControlle...
- ios 判断用户是否开启权限---并跳转“系统设置” 1.判断 访问相册 或 相机 权限是否开启 2.检测是否开启...
- 前言 在ios8.3中,UIAlertView与UIActionSheet已经被列为不建议使用的范畴,按照苹果果断...