mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-02-10 13:06:33 +00:00
Some commit
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user