@@ -75,17 +75,19 @@ - (void)showImage
7575 [self adjustFrame ];
7676 }else if (![_photo.url.absoluteString hasSuffix: @" gif" ]) {
7777 // 不是gif,就马上开始下载
78- __unsafe_unretained MJPhotoView *photoView = self ;
79- __unsafe_unretained MJPhoto *photo = _photo;
78+ ESWeakSelf ;
79+ ESWeak_ ( _photo) ;
8080 [_imageView sd_setImageWithURL: _photo.url placeholderImage: _photo.placeholder options: SDWebImageRetryFailed|SDWebImageLowPriority completed: ^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
81+ ESStrongSelf;
82+ ESStrong_ (_photo);
8183 if (image) {
82- photo .image = image;
84+ __photo .image = image;
8385 }
84- if ([photoView .photoViewDelegate respondsToSelector: @selector (photoViewImageFinishLoad: )]) {
85- [photoView .photoViewDelegate photoViewImageFinishLoad: photoView ];
86+ if ([_self .photoViewDelegate respondsToSelector: @selector (photoViewImageFinishLoad: )]) {
87+ [_self .photoViewDelegate photoViewImageFinishLoad: _self ];
8688 }
8789 // 调整frame参数
88- [photoView adjustFrame ];
90+ [_self adjustFrame ];
8991 }];
9092 }
9193 } else {
@@ -108,14 +110,16 @@ - (void)photoStartLoad
108110 [_photoLoadingView showLoading ];
109111 [self addSubview: _photoLoadingView];
110112
111- __unsafe_unretained MJPhotoView *photoView = self ;
112- __unsafe_unretained MJPhotoLoadingView *loading = _photoLoadingView;
113+ ESWeakSelf ;
114+ ESWeak_ ( _photoLoadingView) ;
113115 [_imageView sd_setImageWithURL: _photo.url placeholderImage: _photo.srcImageView.image options: SDWebImageRetryFailed|SDWebImageLowPriority progress: ^(NSInteger receivedSize, NSInteger expectedSize) {
116+ ESStrong_ (_photoLoadingView);
114117 if (receivedSize > kMinProgress ) {
115- loading .progress = (float )receivedSize/expectedSize;
118+ __photoLoadingView .progress = (float )receivedSize/expectedSize;
116119 }
117120 } completed: ^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
118- [photoView photoDidFinishLoadWithImage: image];
121+ ESStrongSelf;
122+ [_self photoDidFinishLoadWithImage: image];
119123 }];
120124 }
121125}
0 commit comments