diff --git a/Source/ASCollectionView.mm b/Source/ASCollectionView.mm index f997359b7b..d8ab5c0a1c 100644 --- a/Source/ASCollectionView.mm +++ b/Source/ASCollectionView.mm @@ -924,7 +924,9 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier"; ASCellNode *cell = [self nodeForItemAtIndexPath:indexPath]; if (cell.shouldUseUIKitCell) { if ([_asyncDelegate respondsToSelector:@selector(collectionView:layout:sizeForItemAtIndexPath:)]) { - return [(id)_asyncDelegate collectionView:collectionView layout:collectionViewLayout sizeForItemAtIndexPath:indexPath]; + CGSize size = [(id)_asyncDelegate collectionView:collectionView layout:collectionViewLayout sizeForItemAtIndexPath:indexPath]; + cell.style.preferredSize = size; + return size; } } ASCollectionElement *e = [_dataController.visibleMap elementForItemAtIndexPath:indexPath]; @@ -972,13 +974,11 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier"; BOOL shouldDequeueExternally = _asyncDataSourceFlags.interopViewForSupplementaryElement && (_asyncDataSourceFlags.interopAlwaysDequeue || node.shouldUseUIKitCell); if (shouldDequeueExternally) { + // This codepath is used for both IGListKit mode, and app-level UICollectionView interop. view = [(id)_asyncDataSource collectionView:collectionView viewForSupplementaryElementOfKind:kind atIndexPath:indexPath]; } else { - view = [self dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kReuseIdentifier forIndexPath:indexPath]; - } - - if (!node.shouldUseUIKitCell) { ASDisplayNodeAssert(node != nil, @"Supplementary node should exist. Kind = %@, indexPath = %@, collectionDataSource = %@", kind, indexPath, self); + view = [self dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kReuseIdentifier forIndexPath:indexPath]; } if (node) { diff --git a/Source/Details/ASRangeController.mm b/Source/Details/ASRangeController.mm index 024c99384b..5bc4cfb191 100644 --- a/Source/Details/ASRangeController.mm +++ b/Source/Details/ASRangeController.mm @@ -12,7 +12,7 @@ #import #import -#import +#import #import #import #import // Required for interfaceState and hierarchyState setter methods. @@ -444,7 +444,13 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive; ASDisplayNodeAssertMainThread(); ASDisplayNodeAssert(node, @"Cannot move a nil node to a view"); ASDisplayNodeAssert(contentView, @"Cannot move a node to a non-existent view"); - + + if (node.shouldUseUIKitCell) { + // When using UIKit cells, the ASCellNode is just a placeholder object with a preferredSize. + // In this case, we should not disrupt the subviews of the contentView. + return; + } + if (node.view.superview == contentView) { // this content view is already correctly configured return;