Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. //
  2. // ViewController.m
  3. // CollectionViewTest
  4. //
  5. // Created by Dmitriy Y. Volkov on 29/03/16.
  6. // Copyright © 2016 Yandex. All rights reserved.
  7. //
  8.  
  9. #import "ViewController.h"
  10.  
  11. @interface ViewController ()<UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
  12.  
  13. @property(nonatomic, strong) IBOutlet UICollectionView *collectionView;
  14.  
  15. @end
  16.  
  17. @implementation ViewController
  18.  
  19. - (void)viewDidLoad {
  20. self.collectionView.allowsMultipleSelection = YES;
  21. [super viewDidLoad];
  22.  
  23. // Do any additional setup after loading the view, typically from a nib.
  24. }
  25.  
  26. - (void)didReceiveMemoryWarning {
  27. [super didReceiveMemoryWarning];
  28. // Dispose of any resources that can be recreated.
  29. }
  30.  
  31. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  32. {
  33. return 10;
  34. }
  35.  
  36. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  37. {
  38. return [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
  39.  
  40. }
  41.  
  42. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  43. {
  44. UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
  45. cell.backgroundColor = [UIColor redColor];
  46. NSLog(@"selected");
  47. }
  48. - (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
  49. {
  50. UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
  51. cell.backgroundColor = [UIColor blueColor];
  52. NSLog(@"deselected");
  53. }
  54.  
  55.  
  56. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement