Created
December 10, 2013 08:10
-
-
Save MengTo/7887196 to your computer and use it in GitHub Desktop.
Sample of a CollectionViewController with 3 sections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property (nonatomic, strong) NSArray *sections; | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Cell Sections in Array | |
self.sections = @[ | |
@{@"identifier": @"firstCell"}, | |
@{@"identifier": @"secondCell"}, | |
@{@"identifier": @"thirdCell"}, | |
]; | |
} | |
#pragma mark - | |
#pragma mark UICollectionViewDataSource | |
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { | |
return 1; | |
} | |
-(NSInteger)collectionView:(UICollectionView *)collectionView | |
numberOfItemsInSection:(NSInteger)section | |
{ | |
return self.sections.count; | |
} | |
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView | |
cellForItemAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
id object = self.sections[indexPath.row]; | |
UICollectionViewCell *cell = [collectionView | |
dequeueReusableCellWithReuseIdentifier:object[@"identifier"] | |
forIndexPath:indexPath]; | |
return cell; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment