diff --git a/AsyncDisplayKit/ASTextNode.mm b/AsyncDisplayKit/ASTextNode.mm index 8ec7a77a20..b3771ba14d 100644 --- a/AsyncDisplayKit/ASTextNode.mm +++ b/AsyncDisplayKit/ASTextNode.mm @@ -317,6 +317,8 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ]; - (void)calculatedLayoutDidChange { + [super calculatedLayoutDidChange]; + ASLayout *layout = self.calculatedLayout; if (layout != nil) { _constrainedSize = layout.size; diff --git a/_site/docs/containers-ascollectionnode.html b/_site/docs/containers-ascollectionnode.html new file mode 100644 index 0000000000..a009926f9d --- /dev/null +++ b/_site/docs/containers-ascollectionnode.html @@ -0,0 +1,5958 @@ + + + + + AsyncDisplayKit | ASCollectionNode + + + + + + + + + + + + + + + + + + +
+ + + + +
+

+ ASCollectionNode + Edit on GitHub +

+

+ +

ASCollectionNode can be used in place of any UICollectionView. The only requirements are that you replace your

+ +

-cellForRowAtIndexPath:

+ +

method with a

+ +

-nodeForRowAtIndexPath:

+ +

or

+ +

-nodeBlockForRowAtIndexPath:

+ +

Otherwise, a collection node has mostly the same delegate and dataSource methods that a collection view would and is compatible with most UICollectionViewLayouts.

+ + +
+ + + Next → + +
+ + +
+ +
+ + + + + + + diff --git a/_site/docs/containers-aspagernode.html b/_site/docs/containers-aspagernode.html new file mode 100644 index 0000000000..e5cd59a24d --- /dev/null +++ b/_site/docs/containers-aspagernode.html @@ -0,0 +1,5977 @@ + + + + + AsyncDisplayKit | ASPagerNode + + + + + + + + + + + + + + + + + + +
+ + + + +
+

+ ASPagerNode + Edit on GitHub +

+

+ +

ASPagerNode is a specialized subclass of ASCollectionNode. Using it allows you to produce a page style UI similar to what you'd create with a UIPageViewController with UIKit. Luckily, the API is quite a bit simpler than UIPageViewController's.

+ +

The main dataSource methods are:

+ +

- (NSInteger)numberOfPagesInPagerNode:(ASPagerNode *)pagerNode

+ +

and

+ +

- (ASCellNode *)pagerNode:(ASPagerNode *)pagerNode nodeAtIndex:(NSInteger)index

+ +

or

+ +

- (ASCellNodeBlock)pagerNode:(ASPagerNode *)pagerNode nodeBlockAtIndex:(NSInteger)index

+ +

These two methods, just as with ASCollectionNode and ASTableNode need to return either an ASCellNode or an block it can use to return one later.

+ +

One especially useful pattern is to return an ASCellNode that is initialized with an existing UIViewController or ASViewController.

+
- (ASCellNode *)pagerNode:(ASPagerNode *)pagerNode nodeAtIndex:(NSInteger)index
+{
+    CGSize pagerNodeSize = pagerNode.bounds.size;
+    NSArray *animals = self.animals[index];
+
+    ASCellNode *node = [[ASCellNode alloc] initWithViewControllerBlock:^{
+        return [[AnimalTableNodeController alloc] initWithAnimals:animals];;
+    } didLoadBlock:nil];
+
+    node.preferredFrameSize = pagerNodeSize;
+
+    return node;
+}
+
+

In this example, you can see that the node is constructed using the -initWithViewControllerBlock: method. It is usually necessary to provide a cell created this way with a preferredFrameSize so that it can be laid out correctly.

+ + +
+ + + Next → + +
+ + +
+ +
+ + + + + + + diff --git a/_site/docs/containers-astablenode.html b/_site/docs/containers-astablenode.html new file mode 100644 index 0000000000..ee09be631a --- /dev/null +++ b/_site/docs/containers-astablenode.html @@ -0,0 +1,5972 @@ + + + + + AsyncDisplayKit | ASTableNode + + + + + + + + + + + + + + + + + + +
+ + + + +
+

+ ASTableNode + Edit on GitHub +

+

+ +

ASTableNode is equivalent to UIKit's UITableView.

+ +
+If you've used previous versions of ASDK, you'll notice that ASTableView has been removed in favor of ASTableNode. ASTableView (an actual UITableView subclass) is still in use as an internal property of ASTableNode but should no longer be used by itself. + +That being said, you can still grab a reference to the underlying ASTableView if necessary by accessing the .view property of an ASTableNode. +
+ +

ASTableNode can be used in place of any UITableView. The only requirements are that you replace your

+ +

-cellForRowAtIndexPath:

+ +

method with a

+ +

-nodeForRowAtIndexPath:

+ +

or

+ +

-nodeBlockForRowAtIndexPath:

+ +

Otherwise, a table node has mostly the same delegate and dataSource methods that a table view would.

+ +

An important thing to notice is that ASTableNode does not provide a method called:

+ +

-tableNode:HeightForRowAtIndexPath:

+ +

This is because in ASDK, nodes are responsible for determining their height themselves which means you no longer have to write code to determine this detail at the view controller level.

+ + +
+ + + Next → + +
+ + +
+ +
+ + + + + + + diff --git a/_site/docs/containers-asviewcontroller.html b/_site/docs/containers-asviewcontroller.html new file mode 100644 index 0000000000..0ae033facc --- /dev/null +++ b/_site/docs/containers-asviewcontroller.html @@ -0,0 +1,5974 @@ + + + + + AsyncDisplayKit | ASViewController + + + + + + + + + + + + + + + + + + +
+ + + + +
+

+ ASViewController + Edit on GitHub +

+

+ +

ASViewController is a subclass of UIViewController and adds the following features. +- handles the measurement stuff +- handles rotation +- additional memory management to help deep nativation stacks manage memory

+ +

An ASViewController can be used in place of any UIViewController - including within a UINavigationController, UITabBarController and UISpitViewController or as a modal view controller.

+ +

Porting UIViewControllers to ASViewControllers

+ +

A UIViewController provides a view of its own. An ASViewController is assigned a node to manage in its designated initializer initWithNode:.

+ +

Consider the following ASViewController subclass that would like to use a custom table node as its managed node.

+
- (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;
+}
+
+

For a full guide on porting your UIKit app to ASDK see Porting Your App (INCLUDE LINK).

+ +

Example Apps

+ + +
+ + + Next → + +
+ + +
+ +
+ + + + + + + diff --git a/_site/docs/containers-overview.html b/_site/docs/containers-overview.html new file mode 100644 index 0000000000..ea0c47c5fa --- /dev/null +++ b/_site/docs/containers-overview.html @@ -0,0 +1,5967 @@ + + + + + AsyncDisplayKit | Containers Overview + + + + + + + + + + + + + + + + + + +
+ + + + +
+

+ Containers Overview + Edit on GitHub +

+

+ +

Use Nodes in Node Containers

+ +

For optimal performance, use nodes within a node container. ASDK offers the following node containers

+ +
    +
  • ASViewController in place of UIKit's UIViewController
  • +
  • ASCollectioNode in place of UIKit's UICollectionView
  • +
  • ASTableNode in place of UIKit's UITableView
  • +
  • ASPagerNode in place of UIKit's UIPagerView
  • +
+ +

Examples

+ +

Examples of these node containers can be found in the sample projects. Example code and specific sample apps are highlighted in the documentation for each node container.

+ +

For a guide on porting your UIKit app to ASDK see Porting Your App (INCLUDE LINK).

+ +

For the More Curious Developer...

+ +

To optimize performance of an app, ASDK uses intelligent preloading to determine when content will become visible to a user. The node containers above asynchronously trigger data downloading, decoding and rendering of images and text before they reach the device's onscren display area. The node containers above manage all of this automatically for their subnodes. For reference, UIKit does not render images or text before content comes on screen.

+ +

It is possible to use nodes directly, without an ASDK container, but unless you add additional calls, they will only start displaying once they come onscreen, which can lead to performance degredation and flashing of content.

+ + +
+ + + Next → + +
+ + +
+ +
+ + + + + + +