clean up ASCollectionView example project (#2384)

This commit is contained in:
Hannah Troisi
2016-10-20 17:10:20 -07:00
committed by GitHub
parent 1fbcefdbd3
commit 0dd170dde4
4 changed files with 25 additions and 11 deletions

View File

@@ -21,18 +21,17 @@
#import "SupplementaryNode.h"
#import "ItemNode.h"
@interface ViewController ()
@property (nonatomic, strong) ASCollectionView *collectionView;
@property (nonatomic, strong) NSArray *data;
@end
@interface ViewController () <ASCollectionDataSource, ASCollectionViewDelegateFlowLayout>
@property (nonatomic, strong) ASCollectionView *collectionView;
@property (nonatomic, strong) NSArray *data;
@end
@implementation ViewController
#pragma mark - Lifecycle
- (void)dealloc
{
self.collectionView.asyncDataSource = nil;
@@ -52,20 +51,24 @@
// 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.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
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];
#if !SIMULATE_WEB_RESPONSE
self.navigationItem.leftItemsSupplementBackButton = YES;
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(reloadTapped)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(reloadTapped)];
#endif
#if SIMULATE_WEB_RESPONSE
@@ -94,6 +97,8 @@
#endif
}
#pragma mark - Button Actions
- (void)reloadTapped
{
// This method is deprecated because we reccommend using ASCollectionNode instead of ASCollectionView.
@@ -101,8 +106,7 @@
[self.collectionView reloadData];
}
#pragma mark -
#pragma mark ASCollectionView data source.
#pragma mark - ASCollectionView Data Source
- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath;
{