diff --git a/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryComponentView.mm b/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryComponentView.mm index ecaa8bb71e..a47b40b51a 100644 --- a/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryComponentView.mm +++ b/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryComponentView.mm @@ -51,7 +51,7 @@ - (void)didMoveToWindow if (self.window != nil) { [_helper registerForAccessoryFrameChanges]; } else { - [self invalidate]; + [_helper unregisterForAccessoryFrameChanges]; } } diff --git a/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryContentComponentView.mm b/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryContentComponentView.mm index 6d378314fb..e0c87b4b31 100644 --- a/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryContentComponentView.mm +++ b/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryContentComponentView.mm @@ -27,11 +27,15 @@ - (instancetype)initWithFrame:(CGRect)frame - (void)didMoveToWindow { + if (self.window == nil) { + return; + } + if ([self.superview isKindOfClass:[RNSTabsBottomAccessoryComponentView class]]) { RNSTabsBottomAccessoryComponentView *accessoryView = static_cast(self.superview); _accessoryView = accessoryView; - [_accessoryView.helper setContentView:(self.window != nil ? self : nil) forEnvironment:_environment]; + [_accessoryView.helper setContentView:self forEnvironment:_environment]; } else { [_accessoryView.helper setContentView:nil forEnvironment:_environment]; _accessoryView = nil; diff --git a/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryHelper.h b/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryHelper.h index f1a782f5e6..1af5256f08 100644 --- a/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryHelper.h +++ b/ios/tabs/bottom-accessory/RNSTabsBottomAccessoryHelper.h @@ -27,6 +27,10 @@ API_AVAILABLE(ios(26.0)) * `RNSTabBarController`. */ - (void)registerForAccessoryFrameChanges; +/** + * Removes the KVO registration set up by `registerForAccessoryFrameChanges`. + */ +- (void)unregisterForAccessoryFrameChanges; /** * Invalidates observers, display link (if it is used); resets internal properties. */