在图片加载界面,内存暴涨的问题

//参考地址

https://blog.csdn.net/tyforfreedom/article/details/47278975

[imageView.iv sd_setImageWithURL:[NSURL URLWithString:theImage.url] placeholderImage:SharedData.imageAvatarDefaultSmall options:SDWebImageFromCacheOnly completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

                            theImage.image= image;

                        }];

当采用这种方式进行图片加载的时候,图片还会执行下载的操作,缓存到本地。这个时候要对theImage.image = image中model的image弱引用。否则会造成循环引用

#import "KLBaseModel.h"

@interfaceTAvatar :KLBaseModel

@property(nonatomic,assign) NSInteger smsID;

@property(nonatomic,assign) BOOL isGif;

@property(nonatomic,assign) NSInteger width;

@property(nonatomic,assign) NSInteger height;

@property(nonatomic,copy) NSString* url;

@property (nonatomic,strong)UIImage *image;

@property (nonatomic,weak)UIImage *image;

-(CGSize)sizeForWidth:(CGFloat)width;

@end


//注意这种赋值方式也是的(YYImage的图片加载第三方)

//                        [imageView.iv yy_setImageWithURL:[KLUtil getThumbAvatarWithUrl:theImage.url withHeight:_imageHeight withWidth:_imageWidth withOriginWidth:theImage.width orignHeight:theImage.height isGif:theImage.isGif] placeholder:SharedData.imageAvatarDefaultSmall options:YYWebImageOptionProgressive completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {

                    //                            theImage.image = image;

                    //                        }];

你可能感兴趣的:(在图片加载界面,内存暴涨的问题)