From 14765a55d27b58d1b4dce610d815919e10028d7a Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Wed, 23 Nov 2016 15:56:24 -0800 Subject: [PATCH] Revert "Merge pull request #2649 from facebook/AHCollectionNodeInitializer" This reverts commit 0f620f458d815b6f7a6b5d954ac29a6d056caf58, reversing changes made to 0c65d21f8de3023c6d3a25572da18e3b82a35040. --- AsyncDisplayKit/ASCollectionNode.h | 20 +++++-------------- AsyncDisplayKit/ASCollectionNode.mm | 12 +++++------ AsyncDisplayKitTests/ASCollectionViewTests.mm | 11 +++++----- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/AsyncDisplayKit/ASCollectionNode.h b/AsyncDisplayKit/ASCollectionNode.h index eddc915774..ef6e5e9c2a 100644 --- a/AsyncDisplayKit/ASCollectionNode.h +++ b/AsyncDisplayKit/ASCollectionNode.h @@ -33,19 +33,19 @@ NS_ASSUME_NONNULL_BEGIN * * @discussion Initializes and returns a newly allocated collection node object with the specified layout. * - * @param layout The layout object to use for organizing items. The collection node stores a strong reference to the specified object. Must not be nil. + * @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil. */ - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout; /** * Initializes an ASCollectionNode * - * @discussion Initializes and returns a newly allocated collection node object with the specified layout. + * @discussion Initializes and returns a newly allocated collection node object with the specified frame and layout. * - * @param layout The layout object to use for organizing items. The collection node stores a strong reference to the specified object. Must not be nil. - * @param layoutInspector The layout inspector to use, or nil to use the ASDK default layout inspector. + * @param frame The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This frame is passed to the superclass during initialization. + * @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil. */ -- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout layoutInspector:(nullable id)layoutInspector; +- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout; /** * Returns the corresponding ASCollectionView @@ -416,16 +416,6 @@ NS_ASSUME_NONNULL_BEGIN @interface ASCollectionNode (Deprecated) -/** - * Initializes an ASCollectionNode - * - * @discussion Initializes and returns a newly allocated collection node object with the specified frame and layout. - * - * @param frame The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This frame is passed to the superclass during initialization. - * @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil. - */ -- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout ASDISPLAYNODE_DEPRECATED_MSG("Use -initWithCollectionViewLayout: instead."); - /** * Reload everything from scratch, destroying the working range and all cached nodes. * diff --git a/AsyncDisplayKit/ASCollectionNode.mm b/AsyncDisplayKit/ASCollectionNode.mm index ada0803832..de39662d16 100644 --- a/AsyncDisplayKit/ASCollectionNode.mm +++ b/AsyncDisplayKit/ASCollectionNode.mm @@ -111,22 +111,20 @@ - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout { - return [self initWithCollectionViewLayout:layout layoutInspector:nil]; + return [self initWithFrame:CGRectZero collectionViewLayout:layout]; } -- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout layoutInspector:(id)layoutInspector +- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout { - return [self initWithCollectionViewLayout:layout layoutInspector:layoutInspector layoutFacilitator:nil]; + return [self initWithFrame:frame collectionViewLayout:layout layoutFacilitator:nil]; } -- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout layoutInspector:(id)layoutInspector layoutFacilitator:(id)layoutFacilitator +- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout layoutFacilitator:(id)layoutFacilitator { __weak __typeof__(self) weakSelf = self; ASDisplayNodeViewBlock collectionViewBlock = ^UIView *{ __typeof__(self) strongSelf = weakSelf; - ASCollectionView *collectionView = [[ASCollectionView alloc] _initWithFrame:CGRectZero collectionViewLayout:layout layoutFacilitator:layoutFacilitator eventLog:ASDisplayNodeGetEventLog(strongSelf)]; - collectionView.layoutInspector = layoutInspector; - return collectionView; + return [[ASCollectionView alloc] _initWithFrame:frame collectionViewLayout:layout layoutFacilitator:layoutFacilitator eventLog:ASDisplayNodeGetEventLog(strongSelf)]; }; if (self = [super initWithViewBlock:collectionViewBlock]) { diff --git a/AsyncDisplayKitTests/ASCollectionViewTests.mm b/AsyncDisplayKitTests/ASCollectionViewTests.mm index 8f69efecfd..51a4804777 100644 --- a/AsyncDisplayKitTests/ASCollectionViewTests.mm +++ b/AsyncDisplayKitTests/ASCollectionViewTests.mm @@ -148,12 +148,11 @@ self.asyncDelegate = [[ASCollectionViewTestDelegate alloc] initWithNumberOfSections:10 numberOfItemsInSection:10]; id realLayout = [UICollectionViewFlowLayout new]; id mockLayout = [OCMockObject partialMockForObject:realLayout]; - self.collectionNode = [[ASCollectionNode alloc] initWithCollectionViewLayout:mockLayout]; - self.collectionNode.frame = self.view.bounds; - self.collectionNode.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.collectionNode = [[ASCollectionNode alloc] initWithFrame:self.view.bounds collectionViewLayout:mockLayout]; + self.collectionView = self.collectionNode.view; + self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.collectionNode.dataSource = self.asyncDelegate; self.collectionNode.delegate = self.asyncDelegate; - self.collectionView = self.collectionNode.view; [self.collectionNode registerSupplementaryNodeOfKind:UICollectionElementKindSectionHeader]; [self.view addSubview:self.collectionView]; @@ -367,7 +366,7 @@ */ - (void)testThatCollectionNodeConformsToExpectedProtocols { - ASCollectionNode *node = [[ASCollectionNode alloc] initWithCollectionViewLayout:[[UICollectionViewFlowLayout alloc] init]]; + ASCollectionNode *node = [[ASCollectionNode alloc] initWithFrame:CGRectZero collectionViewLayout:[[UICollectionViewFlowLayout alloc] init]]; XCTAssert([node conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)]); } @@ -553,7 +552,7 @@ { UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UICollectionViewLayout *layout = [[UICollectionViewFlowLayout alloc] init]; - ASCollectionNode *cn = [[ASCollectionNode alloc] initWithCollectionViewLayout:layout]; + ASCollectionNode *cn = [[ASCollectionNode alloc] initWithFrame:window.bounds collectionViewLayout:layout]; ASCollectionView *cv = cn.view;