Some commit

This commit is contained in:
Michael Schneider
2016-11-10 16:42:58 -08:00
parent 5226879291
commit c61ba65ba3
8 changed files with 580 additions and 844 deletions

View File

@@ -19,9 +19,36 @@
#import <AsyncDisplayKit/AsyncDisplayKit.h>
#import "DetailRootNode.h"
#import "SampleSizingNode.h"
@interface DetailViewController ()
@property (strong, nonatomic) SampleSizingNode *sizingNode;
@end
@implementation DetailViewController
#pragma mark - Lifecycle
- (instancetype)initWithNode:(DetailRootNode *)node
{
self = [super initWithNode:node];
// Set the sizing delegate of the root node to the container
self.sizingNode = [SampleSizingNode new];
self.sizingNode.autoresizingMask = UIViewAutoresizingNone;
self.sizingNode.delegate = self;
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubnode:self.sizingNode];
}
#pragma mark - Rotation
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
@@ -30,4 +57,32 @@
[self.node.collectionNode.view.collectionViewLayout invalidateLayout];
}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[self updateNodeLayout];
}
#pragma mark - Update the node based on the new size
- (void)displayNodeDidInvalidateSize:(ASDisplayNode *)displayNode
{
// ASDisplayNodeSizingDelegate / ASDisplayNodeSizingHandlers
[self updateNodeLayout];
}
- (void)updateNodeLayout
{
// Adjust the layout on the new layout
// Use the bounds of the view and get the fitting size
CGSize size = [self.sizingNode sizeThatFits:CGSizeMake(CGFLOAT_MAX, 100.0)];
size.width -= 10;
//[self.sizingNode setNeedsLayout];
self.sizingNode.frame = CGRectMake((self.view.bounds.size.width - size.width) / 2.0,
(self.view.bounds.size.height - size.height) / 2.0,
size.width, size.height);
}
@end