您的位置:首页 > 其它

SDWebImage清理缓存及其使用问题

2015-11-17 19:21 417 查看
github地址 : https://github.com/rs/SDWebImage

demo写的清楚缓存按钮方法 ( 使用了 alertController )

float cache = [[SDImageCache sharedImageCache] getSize] / 1024.0 / 1024.0;
NSString *clearCacheName = cache >= 1 ? [NSString stringWithFormat:@"清理缓存(%.2fM)",cache] : [NSString stringWithFormat:@"清理缓存(%.2fK)",cache * 1024];

UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"提示" message:clearCacheName preferredStyle:(UIAlertControllerStyleAlert)];

UIAlertAction *cleanAction = [UIAlertAction actionWithTitle:@"清理" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

[[SDImageCache sharedImageCache] clearDisk];

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"缓存清理完成" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertView show];
}];
[alertC addAction:cancelAction];
[alertC addAction:cleanAction];

[self presentViewController:alertC animated:YES completion:nil];


若有不解 请看:

最新版 SDWebImage:/article/1225764.html

清理缓存方面:http://www.open-open.com/lib/view/open1425625126743.html

/article/2855938.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: