DetailMarkVC.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // DetailMarkVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/1/13.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "DetailMarkVC.h"
  9. #import "markInfo.h"
  10. #import "RGCardViewLayout.h"
  11. #import "DetailMarkCell.h"
  12. @interface DetailMarkVC ()<UICollectionViewDataSource,UICollectionViewDelegate>
  13. {
  14. NSArray *marksArray;
  15. UICollectionView *collection;
  16. RGCardViewLayout *layout;
  17. }
  18. @end
  19. @implementation DetailMarkVC
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. self.view.backgroundColor = backGroundColor;
  23. [self configNavigationBar];
  24. self.title = @"标志详情";
  25. marksArray = [NSArray arrayWithArray:_dataArray];
  26. myDelegate.layoutIndex = _markTag;
  27. [self myInit];
  28. }
  29. -(void)myInit
  30. {
  31. layout = [[RGCardViewLayout alloc] init];
  32. [layout setScrollDirection:UICollectionViewScrollDirectionVertical];
  33. CGFloat width = kFrame.size.width - 30;
  34. CGFloat hight = kFrame.size.height - 100;
  35. [layout setItemSize:CGSizeMake(width, hight)];
  36. [layout setSectionInset:UIEdgeInsetsMake(30, 15, 30, 15)];
  37. layout.isCan = YES;
  38. collection = [[UICollectionView alloc] initWithFrame:kFrame collectionViewLayout:layout];
  39. collection.delegate = self;
  40. collection.dataSource = self;
  41. collection.backgroundColor = backGroundColor;
  42. [collection setPagingEnabled:YES];
  43. [self.view addSubview:collection];
  44. [collection registerClass:[DetailMarkCell class] forCellWithReuseIdentifier:@"detailCell"];
  45. [collection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:_markTag] atScrollPosition:(UICollectionViewScrollPositionCenteredHorizontally) animated:false];
  46. }
  47. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  48. {
  49. return 1;
  50. }
  51. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
  52. {
  53. return marksArray.count;
  54. }
  55. -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  56. {
  57. DetailMarkCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"detailCell" forIndexPath:indexPath];
  58. for (int i = 0; i < marksArray.count; i++)
  59. {
  60. markInfo *info = marksArray[indexPath.section];
  61. cell.imgView.image = [UIImage imageNamed:info.imageName];
  62. cell.titleLabel.text = info.title;
  63. cell.detailLabel.text = info.detail;
  64. }
  65. return cell;
  66. }
  67. - (void)didReceiveMemoryWarning {
  68. [super didReceiveMemoryWarning];
  69. // Dispose of any resources that can be recreated.
  70. }
  71. @end