ChildSymbolVC.m 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // ChildSymbolVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/1/5.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "ChildSymbolVC.h"
  9. #import "symbolCollectionCell.h"
  10. #import "markInfo.h"
  11. #import "DB_Que_Helper.h"
  12. #import "DetailMarkVC.h"
  13. @interface ChildSymbolVC ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
  14. {
  15. NSArray *marksArray;
  16. }
  17. @end
  18. @implementation ChildSymbolVC
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. self.view.backgroundColor = [UIColor whiteColor];
  22. [self configNavigationBar];
  23. NSArray *titleArray = @[@"禁令标志",@"警告标志",@"指示标志",@"指路标志",@"道路施工安全标志",@"旅游区标志",@"辅助标志",@"禁止标线",@"警告标线",@"指示标线",@"道路安全设施设置",@"汽车仪表盘指示灯",@"新版交警手势",@"车内功能按键",@"交通事故责任认定图解",@"色盲测试图集",];
  24. self.title = titleArray[_rowTag];
  25. marksArray = [[NSArray alloc] init];
  26. marksArray = [DB_Que_Helper queryDetailMark:[NSString stringWithFormat:@"MI_GTOUP = %@ and MI_TYPE = %@",_MI_GROUP,_MI_TYPE]];
  27. [self myInit];
  28. }
  29. -(void)myInit
  30. {
  31. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  32. [layout setScrollDirection:UICollectionViewScrollDirectionVertical];
  33. layout.itemSize = SGSizeMake(150, 150);
  34. layout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
  35. UICollectionView *collection = [[UICollectionView alloc] initWithFrame:kFrame collectionViewLayout:layout];
  36. collection.height -= kNavOffSet;
  37. collection.dataSource = self;
  38. collection.delegate = self;
  39. collection.backgroundColor = backGroundColor;
  40. [self.view addSubview:collection];
  41. [collection registerClass:[symbolCollectionCell class] forCellWithReuseIdentifier:@"cell"];
  42. }
  43. #pragma mark collction delegate
  44. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  45. {
  46. return marksArray.count;
  47. }
  48. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  49. {
  50. symbolCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
  51. markInfo *info = marksArray[indexPath.row];
  52. //如果图片名字不对 可以在这里处理
  53. if ([info.imageName rangeOfString:@" 1-1-"].location != NSNotFound)
  54. {
  55. info.imageName = [info.imageName substringFromIndex:1];
  56. }
  57. cell.image.image = [UIImage imageNamed:info.imageName];
  58. cell.nameLabel.text = info.title;
  59. return cell;
  60. }
  61. -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  62. {
  63. DetailMarkVC *detail = [[DetailMarkVC alloc] init];
  64. detail.dataArray = marksArray;
  65. detail.markTag = indexPath.row;
  66. [self navPushHideTabbarToVC:detail];
  67. }
  68. - (void)didReceiveMemoryWarning {
  69. [super didReceiveMemoryWarning];
  70. // Dispose of any resources that can be recreated.
  71. }
  72. /*
  73. #pragma mark - Navigation
  74. // In a storyboard-based application, you will often want to do a little preparation before navigation
  75. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  76. // Get the new view controller using [segue destinationViewController].
  77. // Pass the selected object to the new view controller.
  78. }
  79. */
  80. @end