mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00

git-subtree-dir: submodules/AsyncDisplayKit git-subtree-mainline: d06f423e0ed3df1fed9bd10d79ee312a9179b632 git-subtree-split: 02bedc12816e251ad71777f9d2578329b6d2bef6
1.6 KiB
Executable File
1.6 KiB
Executable File
title | layout | permalink | prevPage | nextPage |
---|---|---|---|---|
ASViewController | docs | /docs/asviewcontroller.html | aspagernode.html |
ASViewController
is a direct subclass of UIViewController
. For the most part, it can be used in place of any UIViewController
relatively easily.
The main difference is that you construct and return the node you'd like managed as opposed to the way UIViewController
provides a view of its own.
Consider the following ASViewController
subclass that would like to use a custom table node as its managed node.
SwiftObjective-C
- (instancetype)initWithModel:(NSArray *)models
{
ASTableNode *tableNode = [[ASTableNode alloc] initWithStyle:UITableViewStylePlain];
if (!(self = [super initWithNode:tableNode])) { return nil; }
self.models = models;
self.tableNode = tableNode;
self.tableNode.dataSource = self;
return self;
}
func initWithModel(models: Array<Model>) {
let tableNode = ASTableNode(style:.Plain)
super.initWithNode(tableNode)
self.models = models
self.tableNode = tableNode
self.tableNode.dataSource = self
return self
}
The most important line is:
if (!(self = [super initWithNode:tableNode])) { return nil; }
As you can see, ASViewController
's are initialized with a node of your choosing.