Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.m
- // CollectionViewTest
- //
- // Created by Dmitriy Y. Volkov on 29/03/16.
- // Copyright © 2016 Yandex. All rights reserved.
- //
- #import "ViewController.h"
- @interface ViewController ()<UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
- @property(nonatomic, strong) IBOutlet UICollectionView *collectionView;
- @end
- @implementation ViewController
- - (void)viewDidLoad {
- self.collectionView.allowsMultipleSelection = YES;
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
- return 10;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- return [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- {
- UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
- cell.backgroundColor = [UIColor redColor];
- NSLog(@"selected");
- }
- - (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
- {
- UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
- cell.backgroundColor = [UIColor blueColor];
- NSLog(@"deselected");
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement