zoukankan      html  css  js  c++  java
  • SDWebImage实现图片展示、缓存、清除缓存

    1.

    /*

    图片显示

    */

            [self.imageView sd_setImageWithURL:[NSURL URLWithString:urlString]];
            
            [self imageCachesWithUrl:[NSURL URLWithString:model.mediumLogo]];

    2.
    /*
    图片缓存
    */
    -(void)imageCachesWithUrl:(NSURL*)url{


        SDWebImageManager *manager = [SDWebImageManager sharedManager];
        
        [manager downloadImageWithURL:url options:SDWebImageRetryFailed progress:^(NSInteger receivedSize, NSInteger expectedSize) {
            
            NSLog(@"显示当前进度");
            
        } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
            
            NSLog(@"下载完成");
        }];

    }

    3./*

    清理图片缓存

    */

    float tmpSize = [[SDImageCache sharedImageCache] getSize];
                    
                    [[SDImageCache sharedImageCache] clearDisk];
                   // float tmpSize = [[SDImageCache sharedImageCache]checkTmpSize];
                   // [[SDWebImageManager sharedManager].imageCache clearMemory];
                    
                   // float tmpSize= [SDWebImageManager sharedManager].imageCache.getSize;
                    NSString *clearCacheName = tmpSize >= 1 ? [NSString stringWithFormat:@"清理缓存(%.2fM)",tmpSize/1000000] : [NSString stringWithFormat:@"清理缓存(%.2fK)",tmpSize/1000];
                    NSLog(@"%@",clearCacheName);

    初探佳境,多多学习交流
  • 相关阅读:
    Android5.0录屏方案
    Android点阵屏效果的控件
    Android绘制View相关的几个问题
    AndroidStudio导入第三方开源库
    第六百二十三天 how can I坚持
    第六百二十二天 how can I 坚持
    第六百二十一天 how can I 坚持
    第六百二十天 how can I 坚持
    第六百一十九天 how can I 坚持
    第六百一十八天 how can I 坚持
  • 原文地址:https://www.cnblogs.com/sunjianfei/p/5512204.html
Copyright © 2011-2022 走看看