DetailMarkVC.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. // markInfo *mark = marksArray[_markTag];
  27. // self.title = mark.title;
  28. myDelegate.layoutIndex = _markTag;
  29. [self myInit];
  30. }
  31. -(void)myInit
  32. {
  33. layout = [[RGCardViewLayout alloc] init];
  34. [layout setScrollDirection:UICollectionViewScrollDirectionVertical];
  35. CGFloat width = kFrame.size.width - 30;
  36. CGFloat hight = kFrame.size.height - 100;
  37. [layout setItemSize:CGSizeMake(width, hight)];
  38. [layout setSectionInset:UIEdgeInsetsMake(30, 15, 30, 15)];
  39. layout.isCan = YES;
  40. collection = [[UICollectionView alloc] initWithFrame:kFrame collectionViewLayout:layout];
  41. collection.height -= kNavOffSet;
  42. collection.delegate = self;
  43. collection.dataSource = self;
  44. collection.backgroundColor = backGroundColor;
  45. [collection setPagingEnabled:YES];
  46. [self.view addSubview:collection];
  47. [collection registerClass:[DetailMarkCell class] forCellWithReuseIdentifier:@"detailCell"];
  48. [collection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:_markTag] atScrollPosition:(UICollectionViewScrollPositionCenteredHorizontally) animated:false];
  49. }
  50. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  51. {
  52. return 1;
  53. }
  54. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
  55. {
  56. return marksArray.count;
  57. }
  58. -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  59. {
  60. DetailMarkCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"detailCell" forIndexPath:indexPath];
  61. for (int i = 0; i < marksArray.count; i++)
  62. {
  63. markInfo *info = marksArray[indexPath.section];
  64. cell.imgView.image = [UIImage imageNamed:info.imageName];
  65. cell.titleLabel.text = info.title;
  66. cell.detailLabel.text = info.detail;
  67. }
  68. return cell;
  69. }
  70. -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  71. {
  72. //标题显示有问题
  73. myDelegate.layoutIndex = indexPath.row;
  74. layout.isCan = YES;
  75. // markInfo *mark = marksArray[indexPath.row];
  76. // self.title = mark.title;
  77. }
  78. - (void)didReceiveMemoryWarning {
  79. [super didReceiveMemoryWarning];
  80. // Dispose of any resources that can be recreated.
  81. }
  82. @end