StrongVC.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. //
  2. // StrongVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/1/13.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "StrongVC.h"
  9. #import "ExerciseVC.h"
  10. #import "StrongCell.h"
  11. #import "PicSymbolTableViewCell.h"
  12. #import "DB_Que_Helper.h"
  13. #import "symbol.h"
  14. #import "ChildSymbolVC.h"
  15. @interface StrongVC ()<UITableViewDataSource,UITableViewDelegate>
  16. {
  17. NSArray *titleArray;
  18. NSMutableArray *countArray;
  19. NSArray *titles;
  20. NSArray *counts;
  21. }
  22. @end
  23. @implementation StrongVC
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. self.view.backgroundColor = backGroundColor;
  27. //导航条颜色
  28. [self.navigationController.navigationBar setBackgroundColor:navBarColor];
  29. [self configNavigationBar];
  30. [self setTitle:@"强化练习"];
  31. [self myInit];
  32. }
  33. -(void)myInit
  34. {
  35. titleArray = @[@"时间",@"距离",@"罚款",@"速度",@"标线",@"标志",@"记分",@"选择",@"图片",@"手势",@"信号灯",@"酒驾",@"灯光",@"仪表",@"装置",@"路况",@"判断",@"动画"];
  36. countArray = [NSMutableArray array];
  37. for (int i = 0; i < 18; i ++) {
  38. NSString *string = titleArray[i];
  39. myDelegate.where = [NSString stringWithFormat:@"kind = '%@' and car_type = '%@' and subject = '%@'",string,defUser.car_type,myDelegate.subject];
  40. if (i == 7) {
  41. myDelegate.where = [NSString stringWithFormat:@"option_type != 0 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject];
  42. }
  43. if (i == 8) {
  44. myDelegate.where = [NSString stringWithFormat:@"media_type = 1 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject];
  45. }
  46. if (i == 16) {
  47. myDelegate.where = [NSString stringWithFormat:@"option_type = 0 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject];
  48. }
  49. if (i == 17) {
  50. myDelegate.where = [NSString stringWithFormat:@"media_type = 2 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject];
  51. }
  52. if (!myDelegate.subject) {
  53. myDelegate.where = [NSString stringWithFormat:@"kind = '%@' and car_type = '%@'",string,defUser.car_type];
  54. if (i == 7) {
  55. myDelegate.where = [NSString stringWithFormat:@"option_type != 0 and car_type = '%@'",defUser.car_type];
  56. }
  57. if (i == 8) {
  58. myDelegate.where = [NSString stringWithFormat:@"media_type = 1 and car_type = '%@'",defUser.car_type];
  59. }
  60. if (i == 16) {
  61. myDelegate.where = [NSString stringWithFormat:@"option_type = 0 and car_type = '%@'",defUser.car_type];
  62. }
  63. if (i == 17) {
  64. myDelegate.where = [NSString stringWithFormat:@"media_type = 2 and car_type = '%@'",defUser.car_type];
  65. }
  66. }
  67. NSInteger count = [DB_Que_Helper countForQuery:@"strong"];
  68. [countArray addObject:[NSString stringWithFormat:@"%ld",(long)count]];
  69. }
  70. titles = @[@"交通标志",@"汽车仪表盘指示灯",@"新版交警手势",@"车内功能按键",@"交通事故责任认定图解",@"色盲测试图集"];
  71. counts = @[@"389",@"21",@"8",@"6",@"35",@"19"];
  72. UITableView *mainTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStyleGrouped];
  73. mainTableView.height -= kNavOffSet;
  74. mainTableView.delegate = self;
  75. mainTableView.dataSource = self;
  76. mainTableView.backgroundColor = backGroundColor;
  77. [self.view addSubview:mainTableView];
  78. }
  79. #pragma mark mainTableView delegate
  80. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  81. {
  82. return 2;
  83. }
  84. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  85. {
  86. if (section == 0)
  87. {
  88. // return titleArray.count/2;
  89. NSInteger number = ceilf([RQ_YDTQuestion_Module getPoint].count / 2.f);
  90. return number;
  91. }
  92. else
  93. {
  94. return titles.count;
  95. }
  96. }
  97. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  98. {
  99. if (indexPath.section == 0)
  100. {
  101. RQYDTPointModel *ydtPointModel = [RQ_YDTQuestion_Module getPoint][indexPath.row];
  102. NSInteger a = ceilf([RQ_YDTQuestion_Module getPoint].count / 2.f);
  103. NSInteger b = indexPath.row + a;
  104. RQYDTPointModel *rightYdtPointModel = b >= [RQ_YDTQuestion_Module getPoint].count? nil : [RQ_YDTQuestion_Module getPoint][indexPath.row + a];
  105. StrongCell *cell = [[[NSBundle mainBundle] loadNibNamed:@"StrongCell" owner:nil options:nil] firstObject];
  106. // cell.titleLabel.text = [NSString stringWithFormat:@"%@ %@",titleArray[indexPath.row],countArray[indexPath.row]];
  107. // cell.rightTitleLabel.text = [NSString stringWithFormat:@"%@ %@",titleArray[indexPath.row + 9],countArray[indexPath.row + 9]];
  108. // cell.indexLabel.text = [NSString stringWithFormat:@"%d",(int)indexPath.row + 1];
  109. // cell.rightIndexLabel.text = [NSString stringWithFormat:@"%d",(int)indexPath.row + 10];
  110. // [cell.btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
  111. // cell.btn.tag = indexPath.row;
  112. // [cell.rightBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
  113. // cell.rightBtn.tag = indexPath.row + 9;
  114. if (ydtPointModel) {
  115. cell.titleLabel.text = [NSString stringWithFormat:@"%@ %ld",ydtPointModel.name,[RQ_YDTQuestion_Module getPointQuestionWithPointID:ydtPointModel.id].count];
  116. [cell.btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
  117. cell.btn.tag = indexPath.row;
  118. cell.indexLabel.backgroundColor = [UIColor qmui_randomColor];
  119. cell.indexLabel.text = [NSString stringWithFormat:@"%d",(int)indexPath.row + 1];
  120. }
  121. if (rightYdtPointModel) {
  122. cell.rightTitleLabel.text = [NSString stringWithFormat:@"%@ %ld",rightYdtPointModel.name,[RQ_YDTQuestion_Module getPointQuestionWithPointID:rightYdtPointModel.id].count];
  123. [cell.rightBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
  124. cell.rightBtn.tag = indexPath.row + a;
  125. cell.rightIndexLabel.backgroundColor = [UIColor qmui_randomColor];
  126. cell.rightIndexLabel.text = [NSString stringWithFormat:@"%ld",(int)indexPath.row + a + 1];
  127. }
  128. // switch (indexPath.row) {
  129. // case 0:
  130. // cell.indexLabel.backgroundColor = [UIColor purpleColor];
  131. // cell.rightIndexLabel.backgroundColor = [UIColor colorWithRed:60/255.0 green:170/255.0 blue:240/255.0 alpha:1];
  132. // break;
  133. // case 1:
  134. // cell.indexLabel.backgroundColor = [UIColor greenColor];
  135. // cell.rightIndexLabel.backgroundColor = [UIColor magentaColor];
  136. // break;
  137. // case 2:
  138. // cell.indexLabel.backgroundColor = [UIColor redColor];
  139. // cell.rightIndexLabel.backgroundColor = [UIColor orangeColor];
  140. // break;
  141. // case 3:
  142. // cell.indexLabel.backgroundColor = [UIColor cyanColor];
  143. // cell.rightIndexLabel.backgroundColor = [UIColor purpleColor];
  144. // break;
  145. // case 4:
  146. // cell.indexLabel.backgroundColor = [UIColor colorWithRed:60/255.0 green:170/255.0 blue:240/255.0 alpha:1];
  147. // cell.rightIndexLabel.backgroundColor = [UIColor greenColor];
  148. // break;
  149. // case 5:
  150. // cell.indexLabel.backgroundColor = [UIColor magentaColor];
  151. // cell.rightIndexLabel.backgroundColor = [UIColor redColor];
  152. // break;
  153. // case 6:
  154. // cell.indexLabel.backgroundColor = [UIColor orangeColor];
  155. // cell.rightIndexLabel.backgroundColor = [UIColor cyanColor];
  156. // break;
  157. // case 7:
  158. // cell.indexLabel.backgroundColor = [UIColor colorWithRed:106/255.0 green:106/255.0 blue:135/255.0 alpha:1];
  159. // cell.rightIndexLabel.backgroundColor = [UIColor colorWithRed:46/255.0 green:103/255.0 blue:95/255.0 alpha:1];
  160. // break;
  161. // case 8:
  162. // cell.indexLabel.backgroundColor = [UIColor colorWithRed:46/255.0 green:103/255.0 blue:95/255.0 alpha:1];
  163. // cell.rightIndexLabel.backgroundColor = [UIColor colorWithRed:106/255.0 green:106/255.0 blue:135/255.0 alpha:1];
  164. // break;
  165. // default:
  166. // break;
  167. // }
  168. return cell;
  169. }
  170. else
  171. {
  172. PicSymbolTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"picSymbol"];
  173. if (!cell)
  174. {
  175. cell = [[PicSymbolTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"picSymbol"];
  176. }
  177. cell.titleLable.text = titles[indexPath.row];
  178. if (indexPath.row == 0)
  179. {
  180. cell.img1.image = [UIImage imageNamed:@"1-1-1.jpg"];
  181. cell.img2.image = [UIImage imageNamed:@"1-1-2.jpg"];
  182. cell.img3.image = [UIImage imageNamed:@"1-1-3.jpg"];
  183. cell.img4.image = [UIImage imageNamed:@"1-1-4.jpg"];
  184. }
  185. else
  186. {
  187. cell.img1.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d-1%d-1.jpg",(int)indexPath.row + 1,(int)indexPath.row + 1]];
  188. cell.img2.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d-1%d-2.jpg",(int)indexPath.row + 1,(int)indexPath.row + 1]];
  189. cell.img3.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d-1%d-3.jpg",(int)indexPath.row + 1,(int)indexPath.row + 1]];
  190. cell.img4.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d-1%d-4.jpg",(int)indexPath.row + 1,(int)indexPath.row + 1]];
  191. }
  192. cell.countLabel.text = counts[indexPath.row];
  193. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  194. return cell;
  195. }
  196. }
  197. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  198. {
  199. if (indexPath.section == 0){
  200. return 44;
  201. }else{
  202. return kFrame.size.width/5.0 + 30;
  203. }
  204. }
  205. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  206. {
  207. if (indexPath.section == 1)
  208. {
  209. if (indexPath.row == 0)
  210. {
  211. symbol *sym = [[symbol alloc] init];
  212. [self navPushHideTabbarToVC:sym];
  213. }else{
  214. ChildSymbolVC *childSym = [[ChildSymbolVC alloc] init];
  215. childSym.rowTag = indexPath.row + 10;
  216. childSym.MI_GROUP = [NSString stringWithFormat:@"%d",(int)indexPath.row + 1];
  217. childSym.MI_TYPE = [NSString stringWithFormat:@"1%d",(int)indexPath.row + 1];
  218. [self navPushHideTabbarToVC:childSym];
  219. }
  220. }
  221. }
  222. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  223. {
  224. UIView * view = [[UIView alloc] init];
  225. view.backgroundColor = backGroundColor;
  226. return view;
  227. }
  228. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  229. {
  230. if (section == 0){
  231. return .1;
  232. }else{
  233. return 20;
  234. }
  235. }
  236. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  237. return [UIView new];
  238. }
  239. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  240. {
  241. if (section == 0){
  242. return .1;
  243. }else{
  244. return .1;
  245. }
  246. }
  247. -(void)click:(UIButton *)btn
  248. {
  249. // NSString *string = titleArray[btn.tag];
  250. //
  251. // myDelegate.where = [NSString stringWithFormat:@"kind = '%@' and car_type = '%@' and subject = '%@'",string,defUser.car_type,myDelegate.subject];
  252. //
  253. // if (btn.tag == 7) {
  254. // myDelegate.where = [NSString stringWithFormat:@"option_type != 0 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject];
  255. // }
  256. // if (btn.tag == 8) {
  257. // myDelegate.where = [NSString stringWithFormat:@"media_type = 1 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject];
  258. // }
  259. // if (btn.tag == 16) {
  260. // myDelegate.where = [NSString stringWithFormat:@"option_type = 0 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject];
  261. // }
  262. // if (btn.tag == 17) {
  263. // myDelegate.where = [NSString stringWithFormat:@"media_type = 2 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject];
  264. // }
  265. //
  266. // if (!myDelegate.subject) {
  267. // myDelegate.where = [NSString stringWithFormat:@"kind = '%@' and car_type = '%@'",string,defUser.car_type];
  268. //
  269. // if (btn.tag == 7) {
  270. // myDelegate.where = [NSString stringWithFormat:@"option_type != 0 and car_type = '%@'",defUser.car_type];
  271. // }
  272. // if (btn.tag == 8) {
  273. // myDelegate.where = [NSString stringWithFormat:@"media_type = 1 and car_type = '%@'",defUser.car_type];
  274. // }
  275. // if (btn.tag == 16) {
  276. // myDelegate.where = [NSString stringWithFormat:@"option_type = 0 and car_type = '%@'",defUser.car_type];
  277. // }
  278. // if (btn.tag == 17) {
  279. // myDelegate.where = [NSString stringWithFormat:@"media_type = 2 and car_type = '%@'",defUser.car_type];
  280. // }
  281. // }
  282. RQYDTPointModel *ydtPointModel = [RQ_YDTQuestion_Module getPoint][btn.tag];
  283. ExerciseVC *vc = [[ExerciseVC alloc] init];
  284. vc.pointId = ydtPointModel.id;
  285. [self navPushHideTabbarToVC:vc];
  286. }
  287. - (void)didReceiveMemoryWarning {
  288. [super didReceiveMemoryWarning];
  289. }
  290. /*
  291. #pragma mark - Navigation
  292. // In a storyboard-based application, you will often want to do a little preparation before navigation
  293. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  294. // Get the new view controller using [segue destinationViewController].
  295. // Pass the selected object to the new view controller.
  296. }
  297. */
  298. @end