mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
clean up ASCollectionView example project (#2384)
This commit is contained in:
@@ -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;
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user