diff --git a/renderer/native/ios/renderer/HippyUIManager.mm b/renderer/native/ios/renderer/HippyUIManager.mm index 0200e99a475..cddf92e26d2 100644 --- a/renderer/native/ios/renderer/HippyUIManager.mm +++ b/renderer/native/ios/renderer/HippyUIManager.mm @@ -826,6 +826,19 @@ - (void)createRenderNodes:(std::vector> &&)nodes [uiManager->_componentTransactionListeners addObject:view]; } [tempCreatedViews addObject:view]; + + // Note: Special logic, to be optimized + // The `onAttachedToWindow` event must be mounted in advance, + // because it will be called in `didUpdateHippySubviews` method. + // Other events are not mounted here. + static constexpr char onAttchedToWindowEventKey[] = "attachedtowindow"; + const std::vector& eventNames = [shadowView allEventNames]; + auto it = std::find(eventNames.begin(), eventNames.end(), onAttchedToWindowEventKey); + if (it != eventNames.end()) { + [uiManager addEventNameInMainThread:onAttchedToWindowEventKey + forView:view + onRootNode:shadowView.rootNode]; + } } }]; } diff --git a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm index 40daabd1b53..d4934955238 100644 --- a/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm +++ b/renderer/native/ios/renderer/component/listview/HippyNextBaseListView.mm @@ -271,11 +271,13 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell UIView *cachedVisibleCellView = [_cachedWeakCellViews objectForKey:shadowView.hippyTag]; if (cachedVisibleCellView) { cellView = cachedVisibleCellView; - HippyLogTrace(@"🟢 use cached visible cellView at %@ for %@", indexPath, shadowView.hippyTag); + HippyLogTrace(@"%@ 🟢 use cached visible cellView at {%ld - %ld} for %@", + self.hippyTag, indexPath.section, indexPath.row, shadowView.hippyTag); } else { cellView = [self.uiManager createViewForShadowListItem:shadowView]; [_cachedWeakCellViews setObject:cellView forKey:shadowView.hippyTag]; - HippyLogTrace(@"🟡 create cellView at %@ for %@", indexPath, shadowView.hippyTag); + HippyLogTrace(@"%@ 🟡 create cellView at {%ld - %ld} for %@", + self.hippyTag, indexPath.section, indexPath.row, shadowView.hippyTag); } HippyAssert([cellView conformsToProtocol:@protocol(ViewAppearStateProtocol)], diff --git a/renderer/native/ios/renderer/component/scrollview/HippyScrollView.mm b/renderer/native/ios/renderer/component/scrollview/HippyScrollView.mm index 4c526add9c5..26a2284dde4 100644 --- a/renderer/native/ios/renderer/component/scrollview/HippyScrollView.mm +++ b/renderer/native/ios/renderer/component/scrollview/HippyScrollView.mm @@ -286,8 +286,7 @@ - (void)removeHippySubview:(UIView *)subview { _contentView = nil; } -- (void)didUpdateHippySubviews -{ +- (void)didUpdateHippySubviews { // Do nothing, as subviews are managed by `insertHippySubview:atIndex:` }