From c6d26c1f4966f1a64da3d433671bbcded322db26 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 17 Dec 2021 17:54:34 +0800 Subject: [PATCH] iOS: image removeObserver when reset --- doric-iOS/Pod/Classes/Shader/DoricImageNode.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m index 5aaa3e68..0d325833 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m @@ -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