Skip to content

Instantly share code, notes, and snippets.

@yoshyosh
Created August 12, 2014 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoshyosh/5538e6bd1ac291406f57 to your computer and use it in GitHub Desktop.
Save yoshyosh/5538e6bd1ac291406f57 to your computer and use it in GitHub Desktop.
//
// ViewController.m
// collection
//
// Created by Joseph Anderson on 8/11/14.
// Copyright (c) 2014 ifd. All rights reserved.
//
#import "ViewController.h"
#import "PhotoLibraryCell.h"
@interface ViewController () <UICollectionViewDelegate, UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.collectionView.dataSource = self;
self.collectionView.delegate = self;
[self.collectionView registerNib:[UINib nibWithNibName:@"PhotoLibraryCell" bundle:nil] forCellWithReuseIdentifier:@"cell"];
UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 20;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
PhotoLibraryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
cell.idLabel.text = [NSString stringWithFormat:@"%ld", (long)indexPath.row];
return cell;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment