iOS: image removeObserver when reset

This commit is contained in:
pengfei.zhou 2021-12-17 17:54:34 +08:00 committed by osborn
parent 5eb47355e0
commit c6d26c1f49

View File

@ -683,6 +683,14 @@ - (void)reset {
self.imageScale = UIScreen.mainScreen.scale;
self.blurEffectView = nil;
self.view.contentMode = UIViewContentModeScaleAspectFill;
if (self.animationEndCallbackId) {
#if DORIC_USE_YYWEBIMAGE
[(DoricImageView *) self.view removeObserver:self forKeyPath:@"currentIsPlayingAnimation" context:nil];
#elif DORIC_USE_SDWEBIMAGE
[(DoricImageView *) self.view removeObserver:self forKeyPath:@"currentFrameIndex" context:nil];
#endif
self.animationEndCallbackId = nil;
}
}
- (BOOL)needReload {
@ -697,10 +705,12 @@ - (BOOL)needReload {
}
- (void)dealloc {
if (self.animationEndCallbackId) {
#if DORIC_USE_YYWEBIMAGE
[(DoricImageView *) self.view removeObserver:self forKeyPath:@"currentIsPlayingAnimation" context:nil];
[(DoricImageView *) self.view removeObserver:self forKeyPath:@"currentIsPlayingAnimation" context:nil];
#elif DORIC_USE_SDWEBIMAGE
[(DoricImageView *) self.view removeObserver:self forKeyPath:@"currentFrameIndex" context:nil];
[(DoricImageView *) self.view removeObserver:self forKeyPath:@"currentFrameIndex" context:nil];
#endif
}
}
@end