diff --git a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.mm b/renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.mm index af0e3bda329..72336dff69f 100644 --- a/renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.mm +++ b/renderer/native/ios/renderer/component/listview/NativeRenderBaseListView.mm @@ -257,8 +257,6 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { HippyShadowView *cellRenderObjectView = [self.dataSource cellForIndexPath:indexPath]; - [cellRenderObjectView recusivelySetCreationTypeToInstant]; - [self itemViewForCollectionViewCell:cell indexPath:indexPath]; NSInteger index = [self.dataSource flatIndexForIndexPath:indexPath]; if (self.onRowWillDisplay) { self.onRowWillDisplay(@{ @@ -284,26 +282,33 @@ - (void)collectionView:(UICollectionView *)collectionView } } -- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { +- (void)collectionView:(UICollectionView *)collectionView + didEndDisplayingCell:(UICollectionViewCell *)cell + forItemAtIndexPath:(NSIndexPath *)indexPath { if ([cell isKindOfClass:[NativeRenderBaseListViewCell class]]) { NativeRenderBaseListViewCell *hpCell = (NativeRenderBaseListViewCell *)cell; if (hpCell.cellView) { [_cachedItems setObject:[hpCell.cellView hippyTag] forKey:indexPath]; - hpCell.cellView = nil; } } } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - return [collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:indexPath]; + UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:indexPath]; + + // Create and Add real Hippy cell content + [self addCellViewToCollectionViewCell:cell atIndexPath:indexPath]; + return cell; } -- (void)itemViewForCollectionViewCell:(UICollectionViewCell *)cell indexPath:(NSIndexPath *)indexPath { +- (void)addCellViewToCollectionViewCell:(UICollectionViewCell *)cell atIndexPath:(NSIndexPath *)indexPath { HippyAssert(self.renderImpl, @"no rendercontext detected"); if (!self.renderImpl) { return; } HippyShadowView *cellRenderObject = [self.dataSource cellForIndexPath:indexPath]; + [cellRenderObject recusivelySetCreationTypeToInstant]; + NativeRenderBaseListViewCell *hpCell = (NativeRenderBaseListViewCell *)cell; UIView *cellView = [self.renderImpl createViewRecursivelyFromRenderObject:cellRenderObject]; if (cellView) { diff --git a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.mm b/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.mm index 58fca6cef16..ca4ca29f7f9 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.mm +++ b/renderer/native/ios/renderer/component/waterfalllist/NativeRenderWaterfallView.mm @@ -71,7 +71,7 @@ - (instancetype)initWithFrame:(CGRect)frame { _scrollListeners = [NSHashTable weakObjectsHashTable]; _scrollEventThrottle = 100.f; _weakItemMap = [NSMapTable strongToWeakObjectsMapTable]; - _cachedItems = [NSMutableDictionary dictionaryWithCapacity:32]; + _cachedItems = [NSMutableDictionary dictionary]; _dataSourcePool = [NSMutableArray array]; _dataSourceSem = dispatch_semaphore_create(1); [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; @@ -369,18 +369,14 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - return [self collectionView:collectionView itemViewForItemAtIndexPath:indexPath]; -} - -- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView itemViewForItemAtIndexPath:(NSIndexPath *)indexPath { NativeRenderWaterfallViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:indexPath]; + [self addCellViewToCollectionViewCell:cell atIndexPath:indexPath]; return cell; } - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { - [self itemViewForCollectionViewCell:cell indexPath:indexPath]; if (0 == [indexPath section] && _containBannerView) { return; } @@ -400,17 +396,18 @@ - (void)collectionView:(UICollectionView *)collectionView } } -- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { +- (void)collectionView:(UICollectionView *)collectionView + didEndDisplayingCell:(UICollectionViewCell *)cell + forItemAtIndexPath:(NSIndexPath *)indexPath { if ([cell isKindOfClass:[NativeRenderWaterfallViewCell class]]) { NativeRenderWaterfallViewCell *hpCell = (NativeRenderWaterfallViewCell *)cell; if (hpCell.cellView) { [_cachedItems setObject:[hpCell.cellView hippyTag] forKey:indexPath]; - hpCell.cellView = nil; } } } -- (void)itemViewForCollectionViewCell:(UICollectionViewCell *)cell indexPath:(NSIndexPath *)indexPath { +- (void)addCellViewToCollectionViewCell:(UICollectionViewCell *)cell atIndexPath:(NSIndexPath *)indexPath { NativeRenderWaterfallViewCell *hpCell = (NativeRenderWaterfallViewCell *)cell; HippyShadowView *renderObjectView = [_dataSource cellForIndexPath:indexPath]; [renderObjectView recusivelySetCreationTypeToInstant];