[Umbrella] ASCollectionView -> ASCollectionNode Migration, Separate Index Spaces (#2372)

* Separate dataSource & UIKit index spaces

Beef up our supplementary node support

Make the API way better

Go nuts

Add a unit test for UICollectionView's handling of reloadData inside batch updates

Wrap indexPathForNode: in a cache

Convert index paths in delegate methods

Go back on table view

Put collection view back

Switch up the API

Move most ASCollectionView API to ASCollectionNode

Move most table logic over to ASTableNode

Do the things

More conversion work

Keep on keepin' on

Get table view delegate API done

More porting

Simplify

Clear the delegate

More cleanup

Move more stuff around

Remove pointless file

Re-add some API

Put back more API

Use the right flag

* Some cleanup

* Remove incorrect comment

* Tweak the API

* Put back a couple methods

* update example projects (note: ASCollectionView deprecation warnings expected)

* change reloadDataWithCompletion:nil --> reloadData

* Clean up rebase

* Make deprecated numberOfItemsInSection methods optional

* Use the right flag

* Address nits

* update ASDKTube, ASDKgram & ASViewController examples
This commit is contained in:
Adlai Holler
2016-10-14 17:21:16 -07:00
committed by GitHub
parent fb768683bc
commit c2ea7cfeac
50 changed files with 3448 additions and 1122 deletions

View File

@@ -26,7 +26,7 @@
@property (nonatomic, strong) NSArray *data;
@end
@interface ViewController () <ASCollectionViewDataSource, ASCollectionViewDelegateFlowLayout>
@interface ViewController () <ASCollectionDataSource, ASCollectionViewDelegateFlowLayout>
@end
@@ -49,12 +49,16 @@
layout.headerReferenceSize = CGSizeMake(50.0, 50.0);
layout.footerReferenceSize = CGSizeMake(50.0, 50.0);
// This method is deprecated because we reccommend using ASCollectionNode instead of ASCollectionView.
// This functionality & example project remains for users who insist on using ASCollectionView.
self.collectionView = [[ASCollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.collectionView.asyncDataSource = self;
self.collectionView.asyncDelegate = self;
self.collectionView.backgroundColor = [UIColor whiteColor];
// This method is deprecated because we reccommend using ASCollectionNode instead of ASCollectionView.
// This functionality & example project remains for users who insist on using ASCollectionView.
[self.collectionView registerSupplementaryNodeOfKind:UICollectionElementKindSectionHeader];
[self.collectionView registerSupplementaryNodeOfKind:UICollectionElementKindSectionFooter];
[self.view addSubview:self.collectionView];
@@ -92,6 +96,8 @@
- (void)reloadTapped
{
// This method is deprecated because we reccommend using ASCollectionNode instead of ASCollectionView.
// This functionality & example project remains for users who insist on using ASCollectionView.
[self.collectionView reloadData];
}

View File

@@ -34,7 +34,6 @@
- (instancetype)init
{
self.navigationItem.title = @"Home";
_tableNode = [[ASTableNode alloc] init];
_tableNode.delegate = self;
_tableNode.dataSource = self;
@@ -42,17 +41,18 @@
if (!(self = [super initWithNode:_tableNode])) {
return nil;
}
[self generateFeedData];
self.navigationItem.title = @"Home";
return self;
}
- (void)loadView
- (void)viewDidLoad
{
[super loadView];
[self generateFeedData];
[_tableNode.view reloadData];
[super viewDidLoad];
[_tableNode reloadData];
}
- (void)generateFeedData
@@ -65,18 +65,23 @@
}
#pragma mark - ASCollectionDelegate - ASCollectionDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- (NSInteger)numberOfSectionsInTableNode:(ASTableNode *)tableNode
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- (NSInteger)tableNode:(ASTableNode *)tableNode numberOfRowsInSection:(NSInteger)section
{
return _videoFeedData.count;
}
- (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath
- (ASCellNode *)tableNode:(ASTableNode *)tableNode nodeForRowAtIndexPath:(NSIndexPath *)indexPath
{
VideoModel *videoObject = [_videoFeedData objectAtIndex:indexPath.row];
VideoContentCell *cellNode = [[VideoContentCell alloc] initWithVideoObject:videoObject];
return cellNode;
}
@end

View File

@@ -50,7 +50,7 @@
_videoFeedData = [[NSMutableArray alloc] initWithObjects:[[VideoModel alloc] init], [[VideoModel alloc] init], nil];
[_tableNode.view reloadData];
[_tableNode reloadData];
}
- (void)viewWillAppear:(BOOL)animated
@@ -63,26 +63,24 @@
}
#pragma mark - ASCollectionDelegate - ASCollectionDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- (NSInteger)numberOfSectionsInTableNode:(ASTableNode *)tableNode
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- (NSInteger)tableNode:(ASTableNode *)tableNode numberOfRowsInSection:(NSInteger)section
{
return _videoFeedData.count;
}
- (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath
- (ASCellNode *)tableNode:(ASTableNode *)tableNode nodeForRowAtIndexPath:(NSIndexPath *)indexPath
{
VideoModel *videoObject = [_videoFeedData objectAtIndex:indexPath.row];
VideoContentCell *cellNode = [[VideoContentCell alloc] initWithVideoObject:videoObject];
return cellNode;
}
//- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath{
// CGFloat fullWidth = [UIScreen mainScreen].bounds.size.width;
// return ASSizeRangeMake(CGSizeMake(fullWidth, 0.0), CGSizeMake(fullWidth, 400.0));
//}
- (ASVideoPlayerNode *)videoPlayerNode;
{
if (_videoPlayerNode) {
@@ -216,4 +214,4 @@
return mainVerticalStack;
}*/
@end
@end

View File

@@ -94,7 +94,7 @@
[_activityIndicatorView stopAnimating];
[self insertNewRowsInTableView:newPhotos];
[self insertNewRowsInTableNode:newPhotos];
// [self requestCommentsForPhotos:newPhotos];
// immediately start second larger fetch
@@ -107,7 +107,7 @@
{
[_photoFeed requestPageWithCompletionBlock:^(NSArray *newPhotos){
[self insertNewRowsInTableView:newPhotos];
[self insertNewRowsInTableNode:newPhotos];
// [self requestCommentsForPhotos:newPhotos];
if (context) {
[context completeBatchFetching:YES];
@@ -133,7 +133,7 @@
// }
//}
- (void)insertNewRowsInTableView:(NSArray *)newPhotos
- (void)insertNewRowsInTableNode:(NSArray *)newPhotos
{
NSInteger section = 0;
NSMutableArray *indexPaths = [NSMutableArray array];
@@ -144,7 +144,7 @@
[indexPaths addObject:path];
}
[_tableNode.view insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
[_tableNode insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
}
- (UIStatusBarStyle)preferredStatusBarStyle
@@ -161,12 +161,12 @@
#pragma mark - ASTableDataSource methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (NSInteger)tableNode:(ASTableNode *)tableNode numberOfRowsInSection:(NSInteger)section
{
return [_photoFeed numberOfItemsInFeed];
}
- (ASCellNodeBlock)tableView:(ASTableView *)tableView nodeBlockForRowAtIndexPath:(NSIndexPath *)indexPath
- (ASCellNodeBlock)tableNode:(ASTableNode *)tableNode nodeBlockForRowAtIndexPath:(NSIndexPath *)indexPath
{
PhotoModel *photoModel = [_photoFeed objectAtIndex:indexPath.row];
// this will be executed on a background thread - important to make sure it's thread safe
@@ -181,7 +181,7 @@
#pragma mark - ASTableDelegate methods
// Receive a message that the tableView is near the end of its data set and more data should be fetched if necessary.
- (void)tableView:(ASTableView *)tableView willBeginBatchFetchWithContext:(ASBatchContext *)context
- (void)tableNode:(ASTableNode *)tableNode willBeginBatchFetchWithContext:(ASBatchContext *)context
{
[context beginBatchFetching];
[self loadPageWithContext:context];
@@ -192,7 +192,7 @@
- (void)resetAllData
{
[_photoFeed clearFeed];
[_tableNode.view reloadData];
[_tableNode reloadData];
[self refreshFeed];
}

View File

@@ -38,9 +38,7 @@
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
{
self.imageNode.position = CGPointZero;
self.imageNode.style.preferredSize = constrainedSize.max;
return [ASAbsoluteLayoutSpec absoluteLayoutSpecWithChildren:@[self.imageNode]];
return [ASRatioLayoutSpec ratioLayoutSpecWithRatio:1.0 child:_imageNode];
}
- (void)layoutDidFinish

View File

@@ -16,17 +16,21 @@
//
#import "DetailRootNode.h"
#import <AsyncDisplayKit/AsyncDisplayKit.h>
#import "DetailCellNode.h"
#import <AsyncDisplayKit/AsyncDisplayKit.h>
static const NSInteger kImageHeight = 200;
@interface DetailRootNode () <ASCollectionViewDataSource, ASCollectionViewDelegate>
@interface DetailRootNode () <ASCollectionDataSource, ASCollectionDelegate>
@property (nonatomic, copy) NSString *imageCategory;
@property (nonatomic, strong) ASCollectionNode *collectionNode;
@end
@implementation DetailRootNode
#pragma mark - Lifecycle
@@ -69,12 +73,12 @@ static const NSInteger kImageHeight = 200;
#pragma mark - ASCollectionDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- (NSInteger)collectionNode:(ASCollectionNode *)collectionNode numberOfItemsInSection:(NSInteger)section
{
return 10;
}
- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *imageCategory = self.imageCategory;
return ^{
@@ -85,9 +89,9 @@ static const NSInteger kImageHeight = 200;
};
}
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath
- (ASSizeRange)collectionNode:(ASCollectionNode *)collectionNode constrainedSizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
CGSize imageSize = CGSizeMake(CGRectGetWidth(collectionView.frame), kImageHeight);
CGSize imageSize = CGSizeMake(CGRectGetWidth(collectionNode.view.frame), kImageHeight);
return ASSizeRangeMake(imageSize, imageSize);
}

View File

@@ -20,13 +20,16 @@
#import "DetailViewController.h"
@interface ViewController () <ASTableDataSource, ASTableDelegate>
@property (nonatomic, copy) NSArray *imageCategories;
@property (nonatomic, strong, readonly) ASTableNode *tableNode;
@end
@implementation ViewController
@implementation ViewController
#pragma mark - Lifecycle
@@ -77,12 +80,12 @@
#pragma mark - ASTableDataSource / ASTableDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (NSInteger)tableNode:(ASTableNode *)tableNode numberOfRowsInSection:(NSInteger)section
{
return self.imageCategories.count;
}
- (ASCellNodeBlock)tableView:(ASTableView *)tableView nodeBlockForRowAtIndexPath:(NSIndexPath *)indexPath
- (ASCellNodeBlock)tableNode:(ASTableNode *)tableNode nodeBlockForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *imageCategory = self.imageCategories[indexPath.row];
return ^{
@@ -92,15 +95,13 @@
};
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- (void)tableNode:(ASTableNode *)tableNode didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *imageCategory = self.imageCategories[indexPath.row];
DetailRootNode *detailRootNode = [[DetailRootNode alloc] initWithImageCategory:imageCategory];
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNode:detailRootNode];
detailViewController.title = [imageCategory capitalizedString];
[self.navigationController pushViewController:detailViewController animated:YES];
}
@end

View File

@@ -15,8 +15,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <UIKit/UIKit.h>
#import <AsyncDisplayKit/AsyncDisplayKit.h>
@interface ViewController : UIViewController
@interface ViewController : ASViewController
@end

View File

@@ -29,9 +29,9 @@ static const NSInteger kBatchSize = 20;
static const CGFloat kHorizontalSectionPadding = 10.0f;
static const CGFloat kVerticalSectionPadding = 20.0f;
@interface ViewController () <ASCollectionViewDataSource, ASCollectionViewDelegateFlowLayout>
@interface ViewController () <ASCollectionDataSource, ASCollectionViewDelegateFlowLayout>
{
ASCollectionView *_collectionView;
ASCollectionNode *_collectionNode;
NSMutableArray *_data;
}
@@ -45,7 +45,7 @@ static const CGFloat kVerticalSectionPadding = 20.0f;
- (instancetype)init
{
self = [super init];
self = [super initWithNode:_collectionNode];
if (self) {
@@ -53,24 +53,23 @@ static const CGFloat kVerticalSectionPadding = 20.0f;
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
_collectionView = [[ASCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.asyncDataSource = self;
_collectionView.asyncDelegate = self;
_collectionView.backgroundColor = [UIColor grayColor];
_collectionView.leadingScreensForBatching = 2;
_collectionNode = [[ASCollectionNode alloc] initWithCollectionViewLayout:layout];
_collectionNode.dataSource = self;
_collectionNode.delegate = self;
_collectionNode.backgroundColor = [UIColor grayColor];
ASRangeTuningParameters preloadTuning;
preloadTuning.leadingBufferScreenfuls = 2;
preloadTuning.trailingBufferScreenfuls = 1;
[_collectionView setTuningParameters:preloadTuning forRangeType:ASLayoutRangeTypePreload];
[_collectionNode setTuningParameters:preloadTuning forRangeType:ASLayoutRangeTypePreload];
ASRangeTuningParameters preRenderTuning;
preRenderTuning.leadingBufferScreenfuls = 1;
preRenderTuning.trailingBufferScreenfuls = 0.5;
[_collectionView setTuningParameters:preRenderTuning forRangeType:ASLayoutRangeTypeDisplay];
[_collectionNode setTuningParameters:preRenderTuning forRangeType:ASLayoutRangeTypeDisplay];
[_collectionView registerSupplementaryNodeOfKind:UICollectionElementKindSectionHeader];
[_collectionView registerSupplementaryNodeOfKind:UICollectionElementKindSectionFooter];
[_collectionNode registerSupplementaryNodeOfKind:UICollectionElementKindSectionHeader];
[_collectionNode registerSupplementaryNodeOfKind:UICollectionElementKindSectionFooter];
_data = [[NSMutableArray alloc] init];
@@ -85,7 +84,8 @@ static const CGFloat kVerticalSectionPadding = 20.0f;
{
[super viewDidLoad];
[self.view addSubview:_collectionView];
// set any collectionView properties here (once the node's backing view is loaded)
_collectionNode.view.leadingScreensForBatching = 2;
[self fetchMoreCatsWithCompletion:nil];
}
@@ -115,10 +115,10 @@ static const CGFloat kVerticalSectionPadding = 20.0f;
- (void)appendMoreItems:(NSInteger)numberOfNewItems completion:(void (^)(BOOL))completion {
NSArray *newData = [self getMoreData:numberOfNewItems];
dispatch_async(dispatch_get_main_queue(), ^{
[_collectionView performBatchUpdates:^{
[_collectionNode performBatchAnimated:YES updates:^{
[_data addObjectsFromArray:newData];
NSArray *addedIndexPaths = [self indexPathsForObjects:newData];
[_collectionView insertItemsAtIndexPaths:addedIndexPaths];
[_collectionNode insertItemsAtIndexPaths:addedIndexPaths];
} completion:completion];
});
}
@@ -142,19 +142,13 @@ static const CGFloat kVerticalSectionPadding = 20.0f;
return indexPaths;
}
- (void)viewWillLayoutSubviews
{
_collectionView.frame = self.view.bounds;
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[_collectionView.collectionViewLayout invalidateLayout];
[_collectionNode.view.collectionViewLayout invalidateLayout];
}
- (void)reloadTapped
{
[_collectionView reloadData];
[_collectionNode reloadData];
}
#pragma mark -

View File

@@ -30,7 +30,7 @@
@end
@protocol MosaicCollectionViewLayoutDelegate <ASCollectionViewDelegate>
@protocol MosaicCollectionViewLayoutDelegate <ASCollectionDelegate>
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(MosaicCollectionViewLayout *)layout originalItemSizeAtIndexPath:(NSIndexPath *)indexPath;
@@ -38,4 +38,4 @@
@interface MosaicCollectionViewLayoutInspector : NSObject <ASCollectionViewLayoutInspecting>
@end
@end

View File

@@ -214,18 +214,6 @@
return ASSizeRangeMake(CGSizeZero, [layout _headerSizeForSection:indexPath.section]);
}
/**
* Asks the inspector for the number of supplementary sections in the collection view for the given kind.
*/
- (NSUInteger)collectionView:(ASCollectionView *)collectionView numberOfSectionsForSupplementaryNodeOfKind:(NSString *)kind
{
if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
return [[collectionView asyncDataSource] numberOfSectionsInCollectionView:collectionView];
} else {
return 0;
}
}
/**
* Asks the inspector for the number of supplementary views for the given kind in the specified section.
*/
@@ -238,4 +226,4 @@
}
}
@end
@end

View File

@@ -16,7 +16,8 @@
//
#import <UIKit/UIKit.h>
#import <AsyncDisplayKit/AsyncDisplayKit.h>
@interface ViewController : UIViewController
@interface ViewController : ASViewController
@end

View File

@@ -23,10 +23,10 @@
static NSUInteger kNumberOfImages = 14;
@interface ViewController () <ASCollectionViewDataSource, MosaicCollectionViewLayoutDelegate>
@interface ViewController () <ASCollectionDataSource, ASCollectionDelegate>
{
NSMutableArray *_sections;
ASCollectionView *_collectionView;
ASCollectionNode *_collectionNode;
MosaicCollectionViewLayoutInspector *_layoutInspector;
}
@@ -39,7 +39,7 @@ static NSUInteger kNumberOfImages = 14;
- (instancetype)init
{
if (!(self = [super init]))
if (!(self = [super initWithNode:_collectionNode]))
return nil;
_sections = [NSMutableArray array];
@@ -59,44 +59,37 @@ static NSUInteger kNumberOfImages = 14;
_layoutInspector = [[MosaicCollectionViewLayoutInspector alloc] init];
_collectionView = [[ASCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.asyncDataSource = self;
_collectionView.asyncDelegate = self;
_collectionView.layoutInspector = _layoutInspector;
_collectionView.backgroundColor = [UIColor whiteColor];
_collectionNode.dataSource = self;
_collectionNode.delegate = self;
_collectionNode.backgroundColor = [UIColor whiteColor];
[_collectionView registerSupplementaryNodeOfKind:UICollectionElementKindSectionHeader];
[_collectionNode registerSupplementaryNodeOfKind:UICollectionElementKindSectionHeader];
return self;
}
- (void)dealloc
{
_collectionView.asyncDataSource = nil;
_collectionView.asyncDelegate = nil;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubview:_collectionView];
_collectionNode.view.layoutInspector = _layoutInspector;
}
- (void)viewWillLayoutSubviews
- (void)dealloc
{
_collectionView.frame = self.view.bounds;
_collectionNode.dataSource = nil;
_collectionNode.delegate = nil;
}
- (void)reloadTapped
{
[_collectionView reloadData];
[_collectionNode reloadData];
}
#pragma mark -
#pragma mark ASCollectionView data source.
- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
{
UIImage *image = _sections[indexPath.section][indexPath.item];
return ^{
@@ -105,7 +98,7 @@ static NSUInteger kNumberOfImages = 14;
}
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *textAttributes = @{
NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline],
@@ -117,17 +110,17 @@ static NSUInteger kNumberOfImages = 14;
return textCellNode;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
- (NSInteger)numberOfSectionsInCollectionView:(ASCollectionNode *)collectionNode
{
return _sections.count;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- (NSInteger)collectionView:(ASCollectionNode *)collectionNode numberOfItemsInSection:(NSInteger)section
{
return [_sections[section] count];
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout originalItemSizeAtIndexPath:(NSIndexPath *)indexPath
- (CGSize)collectionView:(ASCollectionNode *)collectionNode layout:(UICollectionViewLayout *)collectionViewLayout originalItemSizeAtIndexPath:(NSIndexPath *)indexPath
{
return [(UIImage *)_sections[indexPath.section][indexPath.item] size];
}

View File

@@ -21,7 +21,7 @@
* This ASCellNode contains an ASCollectionNode. It intelligently interacts with a containing ASCollectionView or ASTableView,
* to preload and clean up contents as the user scrolls around both vertically and horizontally — in a way that minimizes memory usage.
*/
@interface HorizontalScrollCellNode : ASCellNode <ASCollectionViewDelegate, ASCollectionViewDataSource>
@interface HorizontalScrollCellNode : ASCellNode <ASCollectionDelegate, ASCollectionDataSource>
- (instancetype)initWithElementSize:(CGSize)size;

View File

@@ -15,8 +15,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <UIKit/UIKit.h>
#import <AsyncDisplayKit/AsyncDisplayKit.h>
@interface ViewController : UIViewController
@interface ViewController : ASViewController
@end

View File

@@ -15,15 +15,14 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <AsyncDisplayKit/AsyncDisplayKit.h>
#import <AsyncDisplayKit/ASAssert.h>
#import "ViewController.h"
#import "HorizontalScrollCellNode.h"
@interface ViewController () <ASTableViewDataSource, ASTableViewDelegate>
@interface ViewController () <ASTableDataSource, ASTableDelegate>
{
ASTableView *_tableView;
ASTableNode *_tableNode;
}
@end
@@ -35,13 +34,12 @@
- (instancetype)init
{
if (!(self = [super init]))
if (!(self = [super initWithNode:_tableNode]))
return nil;
_tableView = [[ASTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.asyncDataSource = self;
_tableView.asyncDelegate = self;
_tableNode = [[ASTableNode alloc] initWithStyle:UITableViewStylePlain];
_tableNode.dataSource = self;
_tableNode.delegate = self;
self.title = @"Horizontal Scrolling Gradients";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRedo
@@ -51,21 +49,16 @@
return self;
}
- (void)reloadEverything
{
[_tableView reloadData];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubview:_tableView];
_tableNode.view.separatorStyle = UITableViewCellSeparatorStyleNone;
}
- (void)viewWillLayoutSubviews
- (void)reloadEverything
{
_tableView.frame = self.view.bounds;
[_tableNode reloadData];
}
#pragma mark - ASTableView.