From 9aa4fbb9fa6b5ee5624664a1a2c372f802af12bb Mon Sep 17 00:00:00 2001 From: Luke Parham Date: Tue, 19 Apr 2016 16:13:11 -0500 Subject: [PATCH] fixed broken links, added nifty mailto for 'Email Us' and finished adding preliminary code toggles --- _docs/containers-ascollectionnode.md | 45 ++++++++++++++++++--- _docs/containers-aspagernode.md | 58 +++++++++++++++++++++++----- _docs/containers-astablenode.md | 21 ++++++++-- _docs/layout-engine.md | 2 +- _docs/references.md | 3 +- 5 files changed, 107 insertions(+), 22 deletions(-) diff --git a/_docs/containers-ascollectionnode.md b/_docs/containers-ascollectionnode.md index 2d68ca66..a08c5e71 100755 --- a/_docs/containers-ascollectionnode.md +++ b/_docs/containers-ascollectionnode.md @@ -39,7 +39,10 @@ Consider, the ASViewController subclass - LocationCollectionNodeController - fro An `ASCollectionNode` is assigned to be managed by an `ASViewController` in its `initWithNode:` designated initializer method. -```objective-c +
+SwiftObjective-C +
+
 - (instancetype)initWithCoordinates:(CLLocationCoordinate2D)coordinates
 {
   _flowLayout     = [[UICollectionViewFlowLayout alloc] init];
@@ -53,7 +56,21 @@ An `ASCollectionNode` is assigned to be managed by an `ASViewController` in its
   
   return self;
 }
-```
+
+ + +
+
##Accessing the ASCollectionView## If you've used previous versions of ASDK, you'll notice that `ASCollectionView` has been removed in favor of `ASCollectionNode`. @@ -66,17 +83,33 @@ If you've used previous versions of ASDK, you'll notice that `ASCollectionView` The LocationCollectionNodeController above accesses the ASCollectionView directly in viewDidLoad -```objective-c -- (void)loadView +
+SwiftObjective-C +
+
+- (void)viewDidLoad
 {
-  [super loadView];
+  [super viewDidLoad];
   
   _collectionNode.view.asyncDelegate   = self;
   _collectionNode.view.asyncDataSource = self;
   _collectionNode.view.allowsSelection = NO;
   _collectionNode.view.backgroundColor = [UIColor whiteColor];
 }
-```
+
+ + +
+
##Table Row Height## diff --git a/_docs/containers-aspagernode.md b/_docs/containers-aspagernode.md index c64843ee..5840b164 100755 --- a/_docs/containers-aspagernode.md +++ b/_docs/containers-aspagernode.md @@ -33,40 +33,78 @@ It is imperative that the data model be accessed outside of the node block. This In the example below, you can see how the index is used to access the photo model before creating the node block. -```objective-c +
+SwiftObjective-C +
+
 - (ASCellNodeBlock)pagerNode:(ASPagerNode *)pagerNode nodeBlockAtIndex:(NSInteger)index
 {
-  PhotoModel *photoModel = [_photoFeed objectAtIndex:index];
+  PhotoModel *photoModel = _photoFeed[index];
   
   // this part can be executed on a background thread - it is important to make sure it is thread safe!
-  ASCellNode *(^ASCellNodeBlock)() = ^ASCellNode *() {
-    PhotoCellNode *cellNode = [[PhotoCellNode alloc] initWithPhotoObject:photoModel];
+  ASCellNode *(^cellNodeBlock)() = ^ASCellNode *() {
+    PhotoCellNode *cellNode = [[PhotoCellNode alloc] initWithPhoto:photoModel];
     return cellNode;
   };
   
-  return ASCellNodeBlock;
+  return cellNodeBlock;
 }
-```
+
+ + +
+
##Use ASViewControllers For Optimal Performance## One especially useful pattern is to return an ASCellNode that is initialized with an existing UIViewController or ASViewController. For optimal performance, use an ASViewController. -```objective-c +
+SwiftObjective-C +
+
 - (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;
+    node.preferredFrameSize = pagerNode.bounds.size;
     
     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. ##Sample Apps## diff --git a/_docs/containers-astablenode.md b/_docs/containers-astablenode.md index 13b651d0..afc1aa2f 100755 --- a/_docs/containers-astablenode.md +++ b/_docs/containers-astablenode.md @@ -127,16 +127,31 @@ If you've used previous versions of ASDK, you'll notice that `ASTableView` has b For example, you may want to set a table's separator style property. This can be done by accessing the table node's view in the `viewDidLoad:` method as seen in the example below. -```objective-c +
+SwiftObjective-C +
+
 - (void)viewDidLoad
 {
   [super viewDidLoad];
   
   _tableNode.view.allowsSelection = NO;
   _tableNode.view.separatorStyle = UITableViewCellSeparatorStyleNone;
-  _tableNode.view.leadingScreensForBatching = AUTO_TAIL_LOADING_NUM_SCREENFULS;  // overriding default of 2.0
+  _tableNode.view.leadingScreensForBatching = 3.0;  // overriding default of 2.0
 }
-```
+
+ + +
+
##Table Row Height## diff --git a/_docs/layout-engine.md b/_docs/layout-engine.md index eca23b06..b48c6324 100755 --- a/_docs/layout-engine.md +++ b/_docs/layout-engine.md @@ -2,7 +2,7 @@ title: Layout Engine layout: docs permalink: /docs/layout-engine.html -next: asviewcontroller.html +next: containers-overview.html --- AsyncDisplayKit's layout engine is based on the CSS Box Model. While it is the feature of the framework that bears the weakest resemblance to the UIKit equivalent (AutoLayout), it is also among the most useful features once you've gotten used to it. With enough practice, you may just come to prefer creating declarative layouts to the constraint based approach. ;] diff --git a/_docs/references.md b/_docs/references.md index ecb9f703..4eae545b 100644 --- a/_docs/references.md +++ b/_docs/references.md @@ -10,7 +10,6 @@ next: intelligent-preloading.html For general discussion, announcements and help. Email AsyncDisplayKit@gmail.com for an invite. ###Learn more -- Read the Getting Started guide - Get the sample projects - Browse the API reference - Watch the NSLondon talk or the NSSpain talk @@ -20,4 +19,4 @@ For general discussion, announcements and help. Email AsyncDisplayKit@gmail.com - This is Money - and many more that we don't have permission to put here... -Email us to add your app to this list. +Email us to add your app to this list.