HmV5.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. //
  2. // HmV5.m
  3. // jiaPei
  4. //
  5. // Created by apple on 15/11/13.
  6. // Copyright (c) 2015年 JCZ. All rights reserved.
  7. //
  8. #import "HmV5.h"
  9. #import "AdvertisingColumn.h"
  10. #import "TRListVC.h"
  11. #import "TRDetailVC.h"
  12. #import "VowBar.h"
  13. #import "TopicesVC.h"
  14. @interface HmV5 ()
  15. @end
  16. @implementation HmV5
  17. {
  18. NSMutableArray *btnArr;
  19. AdvertisingColumn *adView;
  20. }
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. [self myInit];
  24. }
  25. - (void)didReceiveMemoryWarning {
  26. [super didReceiveMemoryWarning];
  27. // Dispose of any resources that can be recreated.
  28. }
  29. -(void)myInit
  30. {
  31. self.view.height = self.viewH;
  32. [self.view setBackgroundColor:backGroundColor];
  33. [self configNavigationBar];
  34. btnArr = [NSMutableArray array];
  35. scroll = self.zzScrollV;
  36. [scroll setScrollEnabled:YES];
  37. [self.view addSubview:scroll];
  38. // UIView* hv = [[UIView alloc] initWithFrame:CGRectMake(0, -200, kSize.width, 200)];
  39. // [hv setBackgroundColor:backGroundColor];
  40. // [scroll addSubview:hv];
  41. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateAD:) name:@"updateAD" object:nil];
  42. adView = [[AdvertisingColumn alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.width*9/32.0)];
  43. //广告
  44. NSMutableArray *newAD = [NSMutableArray array];
  45. for (NSDictionary *dic in myDelegate.adArray) {
  46. if ([dic[@"LOCATION"] isEqualToString:@"7"]) {
  47. [newAD addObject:dic];
  48. }
  49. }
  50. [adView setImgArray:newAD];
  51. adView.supVC = self;
  52. [scroll addSubview:adView];
  53. UILabel* label;
  54. UIButton* btn;
  55. NSArray* titles;
  56. CGFloat dx = 15;
  57. CGFloat dy = 10;
  58. CGFloat dH = 40;
  59. int tag = 0;
  60. label = [[UILabel alloc] initWithFrame:CGRectMake(dx, kSize.width*9/32.0+10+dy, kSize.width, dH-dy*2)];
  61. [label setFont:[UIFont scaleSize:NormalFont]];
  62. [label setTextColor:subTitleColor];
  63. [scroll addSubview:label];
  64. [label setText:@"领照须知"];
  65. titles = @[@"驾照年审、年检",@"驾照换证",@"驾照遗失",@"驾照挂失"];
  66. for (int i=0; i<titles.count; i++) {
  67. CGFloat fontSize = NormalFont;
  68. btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/2*(i%2), dH*(int)(i/2) + label.bottom + 10, (kSize.width-1) / 2.f, dH-1)];
  69. [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  70. [btn.titleLabel setFont:[UIFont scaleSize:fontSize]];
  71. [btn setTitleColor:kTitleColor forState:UIControlStateNormal];
  72. [btn setTitle:titles[i] forState:UIControlStateNormal];
  73. [btn setBackgroundColor:[UIColor whiteColor]];
  74. // CGSize titleSize = [btn.titleLabel.text sizeForFont:fontSize];
  75. // [btn setContentEdgeInsets:UIEdgeInsetsMake(0, dx, 0, btn.frame.size.width - dx - titleSize.width)];
  76. [scroll addSubview:btn];
  77. [btnArr addObject:btn];
  78. [btn setTag:tag++];
  79. }
  80. label = [[UILabel alloc] initWithFrame:CGRectMake(dx, btn.bottom + 10 + dy, kSize.width, dH-dy*2)];
  81. [label setFont:[UIFont scaleSize:NormalFont]];
  82. [label setTextColor:subTitleColor];
  83. [scroll addSubview:label];
  84. [label setText:@"新手上路"];
  85. titles = @[@"车辆操作",@"特殊天气驾驶技巧",@"夜间行驶必备",@"刹车技巧",@"事故处理技巧",@"必备停车技巧"];
  86. for (int i=0; i<titles.count; i++)
  87. {
  88. CGFloat fontSize = NormalFont;
  89. btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/2*(i%2), dH*(int)(i/2) + label.bottom + 10, (kSize.width-1) / 2.f, dH-1)];
  90. [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  91. [btn.titleLabel setFont:[UIFont scaleSize:fontSize]];
  92. [btn setTitleColor:kTitleColor forState:UIControlStateNormal];
  93. [btn setTitle:titles[i] forState:UIControlStateNormal];
  94. [btn setBackgroundColor:[UIColor whiteColor]];
  95. // CGSize titleSize = [btn.titleLabel.text sizeForFont:fontSize];
  96. // [btn setContentEdgeInsets:UIEdgeInsetsMake(0, dx, 0, btn.frame.size.width - dx - titleSize.width)];
  97. [scroll addSubview:btn];
  98. [btnArr addObject:btn];
  99. [btn setTag:tag++];
  100. }
  101. //加一项许愿
  102. VowBar *vowItem;
  103. vowItem = [[VowBar alloc] initWithFrame:CGRectMake(0, [[scroll subviews] lastObject].bottom + 10, kFrame.size.width, VAWBAR_H) title:@"下证"];
  104. vowItem.countLabel.text = @"点击参与讨论>>";
  105. [vowItem.topicBtn addTarget:self action:@selector(vowClick:) forControlEvents:UIControlEventTouchUpInside];
  106. vowItem.topicBtn.tag = 11;
  107. [vowItem.vomBtn addTarget:self action:@selector(vowClick:) forControlEvents:UIControlEventTouchUpInside];
  108. vowItem.vomBtn.tag = 12;
  109. // [scroll addSubview:vowItem];
  110. [scroll setContentSize:CGSizeMake(0, CGRectGetMaxY(vowItem.frame)+SCRV_BottomH)];
  111. }
  112. - (void)updateAD:(NSNotification *)notifica
  113. {
  114. NSMutableArray *newAD = [NSMutableArray array];
  115. for (NSDictionary *dic in myDelegate.adArray) {
  116. if ([dic[@"LOCATION"] isEqualToString:@"7"]) {
  117. [newAD addObject:dic];
  118. }
  119. }
  120. [adView setImgArray:newAD];
  121. [[NSNotificationCenter defaultCenter] removeObserver:self name:@"updateAD" object:nil];
  122. }
  123. -(void)vowClick:(UIButton *)btn
  124. {
  125. TopicesVC* vc = [[TopicesVC alloc] init];
  126. vc.type = @"1";
  127. if (btn.tag == 11)
  128. {
  129. vc.groupId = @"8";
  130. }
  131. else
  132. {
  133. vc.groupId = @"9";
  134. }
  135. [self navPushHideTabbarToVC:vc];
  136. }
  137. -(void)btnClick:(UIButton*)sender
  138. {
  139. int tag = (int)sender.tag;
  140. // NSLog(@"btn%d click",(int)sender.tag);
  141. if (9 == tag) {
  142. TRListVC *vc = [[TRListVC alloc] init];
  143. NSArray* arr = @[@"基本停车",
  144. @"垂直式停车位",
  145. @"侧方停车位",
  146. @"斜线停车位",
  147. @"串联式停车",
  148. @"并联式停车",
  149. @"地下车库停车位",
  150. @"非字形停车位"];
  151. [vc setModels:arr];
  152. [vc setTitle:@"必备停车技巧"];
  153. [self navPushHideTabbarToVC:vc];
  154. return;
  155. }
  156. TRDetailVC* vc = [[TRDetailVC alloc] init];
  157. switch (tag) {
  158. case 0:
  159. [vc setFile:@"驾照年审、年检"];
  160. break;
  161. case 1:
  162. [vc setFile:@"驾照换证"];
  163. break;
  164. case 2:
  165. [vc setFile:@"驾照使用指南 - 驾照遗失怎么办?"];
  166. break;
  167. case 3:
  168. [vc setFile:@"驾照挂失"];
  169. break;
  170. case 4:
  171. [vc setFile:@"新手上路指南 - 车辆操作"];
  172. break;
  173. case 5:
  174. [vc setFile:@"新手上路指南 - 特殊天气驾驶技巧"];
  175. break;
  176. case 6:
  177. [vc setFile:@"夜间行驶必备技巧"];
  178. break;
  179. case 7:
  180. [vc setFile:@"刹车技巧"];
  181. break;
  182. case 8:
  183. [vc setFile:@"事故处理技巧"];
  184. break;
  185. default:
  186. break;
  187. }
  188. [self navPushHideTabbarToVC:vc];
  189. }
  190. -(void)dealloc
  191. {
  192. [[NSNotificationCenter defaultCenter] removeObserver:self name:@"updateAD" object:nil];
  193. //下边这个其实不用写的 我们的项目应该不会被用在arc环境下
  194. #if ! __has_feature(objc_arc)
  195. [super dealloc];
  196. #endif
  197. }
  198. @end