diff --git a/renderer/native/ios/renderer/HippyUIManager.h b/renderer/native/ios/renderer/HippyUIManager.h index f4d03aa4aee..51d600d9002 100644 --- a/renderer/native/ios/renderer/HippyUIManager.h +++ b/renderer/native/ios/renderer/HippyUIManager.h @@ -93,6 +93,14 @@ HIPPY_EXTERN NSString *const HippyFontChangeTriggerNotification; - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; +/// Get all rootView +- (NSArray<__kindof UIView *> *)rootViews; + +/// Get rootView with given tag +/// Note: this is root's contentView, +/// NOT the HippyRootView instance! +- (UIView *)rootContentViewForTag:(NSNumber *)rootTag; + /// Gets the view associated with a hippyTag. /// - Parameters: /// - hippyTag: NSNumber @@ -129,9 +137,6 @@ HIPPY_EXTERN NSString *const HippyFontChangeTriggerNotification; /// - Parameter tag: root tag - (void)setNeedsLayoutForRootNodeTag:(NSNumber *)tag; -/// Get all rootView -- (NSArray<__kindof UIView *> *)rootViews; - /// Update view with props - (void)updateView:(NSNumber *)componentTag onRootTag:(NSNumber *)rootTag props:(NSDictionary *)pros; diff --git a/renderer/native/ios/renderer/HippyUIManager.mm b/renderer/native/ios/renderer/HippyUIManager.mm index 140acda23c9..e23a2ab5123 100644 --- a/renderer/native/ios/renderer/HippyUIManager.mm +++ b/renderer/native/ios/renderer/HippyUIManager.mm @@ -285,6 +285,11 @@ - (void)domNodeForComponentTag:(int32_t)componentTag } } +- (UIView *)rootContentViewForTag:(NSNumber *)rootTag { + AssertMainQueue(); + return [_viewRegistry rootComponentForTag:rootTag]; +} + - (UIView *)viewForHippyTag:(NSNumber *)hippyTag onRootTag:(NSNumber *)rootTag { AssertMainQueue(); return [_viewRegistry componentForTag:hippyTag onRootTag:rootTag]; diff --git a/renderer/native/ios/renderer/component/view/UIView+MountEvent.m b/renderer/native/ios/renderer/component/view/UIView+MountEvent.m index 92a3fb59121..771b16c1e31 100644 --- a/renderer/native/ios/renderer/component/view/UIView+MountEvent.m +++ b/renderer/native/ios/renderer/component/view/UIView+MountEvent.m @@ -21,10 +21,13 @@ */ #import "UIView+MountEvent.h" -#import "objc/runtime.h" +#import "HippyUIManager.h" #import "UIView+Hippy.h" +#import "UIView+Render.h" #import "HippyRootView.h" #import "HippyBridge+PerformanceAPI.h" +#import + /// The FCP Notification Imp const NSNotificationName HippyFirstContentfulPaintEndNotification = @"HippyFirstContentfulPaintEndNotification"; @@ -95,8 +98,10 @@ - (void)viewDidUnmoundEvent { - (void)sendAttachedToWindowEvent { if (HippyPaintTypeFCP == self.paintType) { - HippyRootView *rootView = (HippyRootView *)[self hippyRootView]; - [rootView sendFCPNotiIfNeeded:self]; + NSNumber *rootTag = [self rootTag]; + HippyUIManager *uiManager = [self uiManager]; + UIView *rootContentView = [uiManager rootContentViewForTag:rootTag]; + [(HippyRootView *)rootContentView.superview sendFCPNotiIfNeeded:self]; } if (self.onAttachedToWindow) { self.onAttachedToWindow(nil);