Skip to content

Commit 5e34f10

Browse files
committed
added sample app that initializes ASCollectionView cells using view controllers, wip though
1 parent f5d06c5 commit 5e34f10

55 files changed

Lines changed: 1589 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AsyncDisplayKit/ASCellNode.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ - (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlo
4040

4141
- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock
4242
{
43-
ASDisplayNodeAssertNotSupported();
44-
return nil;
43+
return [super initWithViewBlock:viewBlock didLoadBlock:didLoadBlock];
44+
// ASDisplayNodeAssertNotSupported();
45+
// return nil;
4546
}
4647

4748
- (void)setLayerBacked:(BOOL)layerBacked

AsyncDisplayKit/ASDisplayNode.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
*/
2323
typedef UIView *(^ASDisplayNodeViewBlock)();
2424

25+
/**
26+
* UIView creation block. Used to create the backing view of a new display node.
27+
*/
28+
typedef UIViewController *(^ASDisplayNodeViewControllerBlock)();
29+
2530
/**
2631
* CALayer creation block. Used to create the backing layer of a new display node.
2732
*/
@@ -94,6 +99,9 @@ typedef NS_OPTIONS(NSUInteger, ASInterfaceState)
9499
- (id)init;
95100

96101

102+
- (id)initWithViewControllerBlock:(ASDisplayNodeViewControllerBlock)viewControllerBlock;
103+
- (id)initWithViewControllerBlock:(ASDisplayNodeViewControllerBlock)viewControllerBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock;
104+
97105
/**
98106
* @abstract Alternative initializer with a block to create the backing view.
99107
*

AsyncDisplayKit/ASDisplayNode.mm

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,25 @@ - (id)initWithLayerClass:(Class)layerClass
251251
return self;
252252
}
253253

254+
- (id)initWithViewControllerBlock:(ASDisplayNodeViewControllerBlock)viewControllerBlock
255+
{
256+
return [self initWithViewControllerBlock:viewControllerBlock didLoadBlock:nil];
257+
}
258+
259+
- (id)initWithViewControllerBlock:(ASDisplayNodeViewControllerBlock)viewControllerBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock
260+
{
261+
if (!(self = [super init]))
262+
return nil;
263+
264+
ASDisplayNodeAssertNotNil(viewControllerBlock, @"should initialize with a valid block that returns a UIViewController");
265+
266+
return [self initWithViewBlock:^UIView *{
267+
UIViewController *vc = viewControllerBlock();
268+
vc.view.clipsToBounds = YES; // not sure this is the way to go, doesn't really make it better per se
269+
return vc.view;
270+
} didLoadBlock:didLoadBlock];
271+
}
272+
254273
- (id)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock
255274
{
256275
return [self initWithViewBlock:viewBlock didLoadBlock:nil];
@@ -271,7 +290,6 @@ - (id)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(ASDispla
271290
return self;
272291
}
273292

274-
275293
- (id)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock
276294
{
277295
return [self initWithLayerBlock:layerBlock didLoadBlock:nil];
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://github.com/CocoaPods/Specs.git'
2+
platform :ios, '8.0'
3+
pod 'AsyncDisplayKit', :path => '../..'

0 commit comments

Comments
 (0)