// // StrongVC.m // jiaPei // // Created by apple on 16/1/13. // Copyright © 2016年 JCZ. All rights reserved. // #import "StrongVC.h" #import "ExerciseVC.h" #import "StrongCell.h" #import "PicSymbolTableViewCell.h" #import "DB_Que_Helper.h" #import "symbol.h" #import "ChildSymbolVC.h" @interface StrongVC () { NSArray *titleArray; NSMutableArray *countArray; NSArray *titles; NSArray *counts; } @end @implementation StrongVC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = backGroundColor; //导航条颜色 [self.navigationController.navigationBar setBackgroundColor:navBarColor]; [self configNavigationBar]; [self setTitle:@"强化练习"]; [self myInit]; } -(void)myInit { titleArray = @[@"时间",@"距离",@"罚款",@"速度",@"标线",@"标志",@"记分",@"选择",@"图片",@"手势",@"信号灯",@"酒驾",@"灯光",@"仪表",@"装置",@"路况",@"判断",@"动画"]; countArray = [NSMutableArray array]; for (int i = 0; i < 18; i ++) { NSString *string = titleArray[i]; myDelegate.where = [NSString stringWithFormat:@"kind = '%@' and car_type = '%@' and subject = '%@'",string,defUser.car_type,myDelegate.subject]; if (i == 7) { myDelegate.where = [NSString stringWithFormat:@"option_type != 0 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject]; } if (i == 8) { myDelegate.where = [NSString stringWithFormat:@"media_type = 1 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject]; } if (i == 16) { myDelegate.where = [NSString stringWithFormat:@"option_type = 0 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject]; } if (i == 17) { myDelegate.where = [NSString stringWithFormat:@"media_type = 2 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject]; } if (!myDelegate.subject) { myDelegate.where = [NSString stringWithFormat:@"kind = '%@' and car_type = '%@'",string,defUser.car_type]; if (i == 7) { myDelegate.where = [NSString stringWithFormat:@"option_type != 0 and car_type = '%@'",defUser.car_type]; } if (i == 8) { myDelegate.where = [NSString stringWithFormat:@"media_type = 1 and car_type = '%@'",defUser.car_type]; } if (i == 16) { myDelegate.where = [NSString stringWithFormat:@"option_type = 0 and car_type = '%@'",defUser.car_type]; } if (i == 17) { myDelegate.where = [NSString stringWithFormat:@"media_type = 2 and car_type = '%@'",defUser.car_type]; } } NSInteger count = [DB_Que_Helper countForQuery:@"strong"]; [countArray addObject:[NSString stringWithFormat:@"%ld",(long)count]]; } titles = @[@"交通标志",@"汽车仪表盘指示灯",@"新版交警手势",@"车内功能按键",@"交通事故责任认定图解",@"色盲测试图集"]; counts = @[@"389",@"21",@"8",@"6",@"35",@"19"]; UITableView *mainTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStyleGrouped]; mainTableView.height -= kNavOffSet; mainTableView.delegate = self; mainTableView.dataSource = self; mainTableView.backgroundColor = backGroundColor; [self.view addSubview:mainTableView]; } #pragma mark mainTableView delegate -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 0) { // return titleArray.count/2; NSInteger number = ceilf([RQ_YDTQuestion_Module getPoint].count / 2.f); return number; } else { return titles.count; } } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { RQYDTPointModel *ydtPointModel = [RQ_YDTQuestion_Module getPoint][indexPath.row]; NSInteger a = ceilf([RQ_YDTQuestion_Module getPoint].count / 2.f); NSInteger b = indexPath.row + a; RQYDTPointModel *rightYdtPointModel = b >= [RQ_YDTQuestion_Module getPoint].count? nil : [RQ_YDTQuestion_Module getPoint][indexPath.row + a]; StrongCell *cell = [[[NSBundle mainBundle] loadNibNamed:@"StrongCell" owner:nil options:nil] firstObject]; // cell.titleLabel.text = [NSString stringWithFormat:@"%@ %@",titleArray[indexPath.row],countArray[indexPath.row]]; // cell.rightTitleLabel.text = [NSString stringWithFormat:@"%@ %@",titleArray[indexPath.row + 9],countArray[indexPath.row + 9]]; // cell.indexLabel.text = [NSString stringWithFormat:@"%d",(int)indexPath.row + 1]; // cell.rightIndexLabel.text = [NSString stringWithFormat:@"%d",(int)indexPath.row + 10]; // [cell.btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; // cell.btn.tag = indexPath.row; // [cell.rightBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; // cell.rightBtn.tag = indexPath.row + 9; if (ydtPointModel) { cell.titleLabel.text = [NSString stringWithFormat:@"%@ %ld",ydtPointModel.name,[RQ_YDTQuestion_Module getPointQuestionWithPointID:ydtPointModel.id].count]; [cell.btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; cell.btn.tag = indexPath.row; cell.indexLabel.backgroundColor = [UIColor qmui_randomColor]; cell.indexLabel.text = [NSString stringWithFormat:@"%d",(int)indexPath.row + 1]; } if (rightYdtPointModel) { cell.rightTitleLabel.text = [NSString stringWithFormat:@"%@ %ld",rightYdtPointModel.name,[RQ_YDTQuestion_Module getPointQuestionWithPointID:rightYdtPointModel.id].count]; [cell.rightBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; cell.rightBtn.tag = indexPath.row + a; cell.rightIndexLabel.backgroundColor = [UIColor qmui_randomColor]; cell.rightIndexLabel.text = [NSString stringWithFormat:@"%ld",(int)indexPath.row + a + 1]; } // switch (indexPath.row) { // case 0: // cell.indexLabel.backgroundColor = [UIColor purpleColor]; // cell.rightIndexLabel.backgroundColor = [UIColor colorWithRed:60/255.0 green:170/255.0 blue:240/255.0 alpha:1]; // break; // case 1: // cell.indexLabel.backgroundColor = [UIColor greenColor]; // cell.rightIndexLabel.backgroundColor = [UIColor magentaColor]; // break; // case 2: // cell.indexLabel.backgroundColor = [UIColor redColor]; // cell.rightIndexLabel.backgroundColor = [UIColor orangeColor]; // break; // case 3: // cell.indexLabel.backgroundColor = [UIColor cyanColor]; // cell.rightIndexLabel.backgroundColor = [UIColor purpleColor]; // break; // case 4: // cell.indexLabel.backgroundColor = [UIColor colorWithRed:60/255.0 green:170/255.0 blue:240/255.0 alpha:1]; // cell.rightIndexLabel.backgroundColor = [UIColor greenColor]; // break; // case 5: // cell.indexLabel.backgroundColor = [UIColor magentaColor]; // cell.rightIndexLabel.backgroundColor = [UIColor redColor]; // break; // case 6: // cell.indexLabel.backgroundColor = [UIColor orangeColor]; // cell.rightIndexLabel.backgroundColor = [UIColor cyanColor]; // break; // case 7: // cell.indexLabel.backgroundColor = [UIColor colorWithRed:106/255.0 green:106/255.0 blue:135/255.0 alpha:1]; // cell.rightIndexLabel.backgroundColor = [UIColor colorWithRed:46/255.0 green:103/255.0 blue:95/255.0 alpha:1]; // break; // case 8: // cell.indexLabel.backgroundColor = [UIColor colorWithRed:46/255.0 green:103/255.0 blue:95/255.0 alpha:1]; // cell.rightIndexLabel.backgroundColor = [UIColor colorWithRed:106/255.0 green:106/255.0 blue:135/255.0 alpha:1]; // break; // default: // break; // } return cell; } else { PicSymbolTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"picSymbol"]; if (!cell) { cell = [[PicSymbolTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"picSymbol"]; } cell.titleLable.text = titles[indexPath.row]; if (indexPath.row == 0) { cell.img1.image = [UIImage imageNamed:@"1-1-1.jpg"]; cell.img2.image = [UIImage imageNamed:@"1-1-2.jpg"]; cell.img3.image = [UIImage imageNamed:@"1-1-3.jpg"]; cell.img4.image = [UIImage imageNamed:@"1-1-4.jpg"]; } else { cell.img1.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d-1%d-1.jpg",(int)indexPath.row + 1,(int)indexPath.row + 1]]; cell.img2.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d-1%d-2.jpg",(int)indexPath.row + 1,(int)indexPath.row + 1]]; cell.img3.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d-1%d-3.jpg",(int)indexPath.row + 1,(int)indexPath.row + 1]]; cell.img4.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d-1%d-4.jpg",(int)indexPath.row + 1,(int)indexPath.row + 1]]; } cell.countLabel.text = counts[indexPath.row]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; return cell; } } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0){ return 44; }else{ return kFrame.size.width/5.0 + 30; } } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 1) { if (indexPath.row == 0) { symbol *sym = [[symbol alloc] init]; [self navPushHideTabbarToVC:sym]; }else{ ChildSymbolVC *childSym = [[ChildSymbolVC alloc] init]; childSym.rowTag = indexPath.row + 10; childSym.MI_GROUP = [NSString stringWithFormat:@"%d",(int)indexPath.row + 1]; childSym.MI_TYPE = [NSString stringWithFormat:@"1%d",(int)indexPath.row + 1]; [self navPushHideTabbarToVC:childSym]; } } } -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView * view = [[UIView alloc] init]; view.backgroundColor = backGroundColor; return view; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { if (section == 0){ return .1; }else{ return 20; } } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ return [UIView new]; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { if (section == 0){ return .1; }else{ return .1; } } -(void)click:(UIButton *)btn { // NSString *string = titleArray[btn.tag]; // // myDelegate.where = [NSString stringWithFormat:@"kind = '%@' and car_type = '%@' and subject = '%@'",string,defUser.car_type,myDelegate.subject]; // // if (btn.tag == 7) { // myDelegate.where = [NSString stringWithFormat:@"option_type != 0 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject]; // } // if (btn.tag == 8) { // myDelegate.where = [NSString stringWithFormat:@"media_type = 1 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject]; // } // if (btn.tag == 16) { // myDelegate.where = [NSString stringWithFormat:@"option_type = 0 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject]; // } // if (btn.tag == 17) { // myDelegate.where = [NSString stringWithFormat:@"media_type = 2 and car_type = '%@' and subject = '%@'",defUser.car_type,myDelegate.subject]; // } // // if (!myDelegate.subject) { // myDelegate.where = [NSString stringWithFormat:@"kind = '%@' and car_type = '%@'",string,defUser.car_type]; // // if (btn.tag == 7) { // myDelegate.where = [NSString stringWithFormat:@"option_type != 0 and car_type = '%@'",defUser.car_type]; // } // if (btn.tag == 8) { // myDelegate.where = [NSString stringWithFormat:@"media_type = 1 and car_type = '%@'",defUser.car_type]; // } // if (btn.tag == 16) { // myDelegate.where = [NSString stringWithFormat:@"option_type = 0 and car_type = '%@'",defUser.car_type]; // } // if (btn.tag == 17) { // myDelegate.where = [NSString stringWithFormat:@"media_type = 2 and car_type = '%@'",defUser.car_type]; // } // } RQYDTPointModel *ydtPointModel = [RQ_YDTQuestion_Module getPoint][btn.tag]; ExerciseVC *vc = [[ExerciseVC alloc] init]; vc.pointId = ydtPointModel.id; [self navPushHideTabbarToVC:vc]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end