@@ -161,8 +161,9 @@ - (void)updateImageWithKeys:(NSMutableArray *)newImageKeys
161161 if ([requestImageKeys count ] != 0 )
162162 {
163163 __block NSUInteger totalCount = [requestImageKeys count ];
164- __block NSUInteger process = 0 ;
165- NSString *message = [NSString stringWithFormat: @" 正在加载图片(进度:%lu /%lu )" , process, totalCount];
164+ __block NSUInteger progress = 0 ;
165+ __block BOOL sendNotification = YES ;
166+ NSString *message = [NSString stringWithFormat: @" 正在加载图片(进度:%lu /%lu )" , progress, totalCount];
166167 NSDictionary *userInfo = @{ @" message" : message };
167168 [[NSNotificationCenter defaultCenter ] postNotificationName: kDXEDidLoadingProgressNotification object: self userInfo: userInfo];
168169 for (NSString *imageKey in requestImageKeys)
@@ -172,25 +173,35 @@ - (void)updateImageWithKeys:(NSMutableArray *)newImageKeys
172173 {
173174 if (finished)
174175 {
176+ NSDictionary *userInfo;
175177 if (error)
176178 {
177179 NSLog (@" Get image %@ : %@ " , imageURL, error);
178- process++;
180+ NSString *message = [NSString stringWithFormat: @" 加载图片错误,请检查网络与后台后再次进入" ];
181+ userInfo = @{ @" error" : message };
179182 }
180183 else if (image && finished)
181184 {
182185 NSLog (@" %@ " , [imageURL absoluteString ]);
183186 [[SDWebImageManager sharedManager ].imageCache storeImage: image forKey: imageKey];
184187
185- process++;
188+ progress++;
189+
190+ NSString *message = [NSString stringWithFormat: @" 正在加载图片(进度:%lu /%lu )" , progress, totalCount];
191+ userInfo = @{ @" message" : message };
186192 }
187193
188- NSString *message = [NSString stringWithFormat: @" 正在加载图片(进度:%lu /%lu )" , process, totalCount];
189- NSDictionary *userInfo = @{ @" message" : message };
190- [[NSNotificationCenter defaultCenter ] postNotificationName: kDXEDidLoadingProgressNotification object: self userInfo: userInfo];
191- if (process == totalCount)
194+ if (sendNotification)
192195 {
193- [[NSNotificationCenter defaultCenter ] postNotificationName: kDXEDidFinishLoadingNotification object: self ];
196+ [[NSNotificationCenter defaultCenter ] postNotificationName: kDXEDidLoadingProgressNotification object: self userInfo: userInfo];
197+ if (progress == totalCount)
198+ {
199+ [[NSNotificationCenter defaultCenter ] postNotificationName: kDXEDidFinishLoadingNotification object: self ];
200+ }
201+ if (error)
202+ {
203+ sendNotification = NO ;
204+ }
194205 }
195206 }
196207 }];
0 commit comments