Last active
December 24, 2015 12:12
-
-
Save MaximAlien/68d9027767916ce0cddf to your computer and use it in GitHub Desktop.
[iOS] Stub used for quick UICollectionView integration
This file contains 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
// ViewController.h | |
#import <UIKit/UIKit.h> | |
@interface ViewController : UIViewController <UICollectionViewDelegate, UICollectionViewDataSource> | |
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView; | |
@end | |
// ViewController.m | |
#import "PermissionsViewController.h" | |
@interface PermissionsViewController () | |
@end | |
@implementation PermissionsViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
self.collectionView.delegate = self; | |
self.collectionView.dataSource = self; | |
// [self.collectionView registerNib:[UINib nibWithNibName:@"CustomCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"CustomCollectionViewCell"]; | |
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"UICollectionViewCell"]; | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
} | |
#pragma mark - UICollectionView delegate methods | |
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section | |
{ | |
return 20; | |
} | |
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
return CGSizeMake(200, 200); | |
} | |
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"UICollectionViewCell" forIndexPath:indexPath]; | |
cell.backgroundColor = [UIColor whiteColor]; | |
return cell; | |
} | |
// Custom UICollectionViewCell | |
//- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath | |
//{ | |
// CustomCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CustomCollectionViewCell" forIndexPath:indexPath]; | |
// | |
// cell.backgroundColor = [UIColor whiteColor]; | |
// | |
// return cell; | |
//} | |
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section | |
{ | |
return UIEdgeInsetsMake(5, 5, 5, 5); | |
} | |
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionView *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section | |
{ | |
return 5; | |
} | |
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section | |
{ | |
return 5; | |
} | |
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment