// // JXExamViewController.m // shiku_im // // Created by qiudezheng on 2020/4/29. // Copyright © 2020 Reese. All rights reserved. // #import "JXQuestionnVc.h" #import "JXQuestionCell.h" #import "JXApplyViewController.h" @interface JXQuestionnVc () @property(strong,nonatomic)UIView * navigationView; @property(strong,nonatomic)UIView * alertViews; @property(strong,nonatomic)UILabel * alertLabel; @property(strong,nonatomic)UILabel * countLabel; @property(strong,nonatomic)UIButton * backButton; @property(strong,nonatomic)UILabel * questionLabel; @property(strong,nonatomic)UILabel * questionTitle; @property(strong,nonatomic)UITableView * questionTable; @property(strong,nonatomic)UIScrollView * scrollView; @property(strong,nonatomic)NSArray * questionArray; @property(assign,nonatomic)NSUInteger currentSort; @property(strong,nonatomic)NSDictionary * currentQuestion; @property(strong,nonatomic)NSTimer * timer; @property(assign,nonatomic)int count; @property (nonatomic,assign) NSInteger indexRightRow; @property (nonatomic,strong) NSMutableArray *dataArr; @property (nonatomic,strong) NSMutableArray *firstArr; @property (nonatomic,strong) NSMutableArray *questionArr; @property (nonatomic,strong) NSMutableArray *ruleArr; @property (nonatomic,assign) NSInteger indexRecordIndex; @property (nonatomic,assign) NSInteger indexRow; @property (nonatomic,strong) NSMutableArray *saveSelectIndexArr; @property (nonatomic,strong) NSMutableDictionary *saveSelectIndexDict; @property (nonatomic,weak) UIAlertView * aler; @property (nonatomic,strong) NSMutableArray *dataArr222; @property (nonatomic,strong) NSMutableArray *dataArr333; @end @implementation JXQuestionnVc -(void)viewWillDisappear:(BOOL)animated { [SVProgressHUD dismiss]; } - (void)viewDidLoad { [super viewDidLoad]; _currentQuestion=[NSDictionary dictionary]; _indexRightRow=100; _indexRow=200; //保存选中的数据 _saveSelectIndexArr=[NSMutableArray array]; _saveSelectIndexDict=[NSMutableDictionary dictionary]; _firstArr=[NSMutableArray array]; _dataArr222=[NSMutableArray array]; _dataArr333=[NSMutableArray array]; _dataArr=[NSMutableArray array]; _questionArr=[NSMutableArray array]; _ruleArr=[NSMutableArray array]; self.view.backgroundColor = [UIColor colorWithRed:126/255.0f green:23/255.0f blue:21/255.0f alpha:1.0f]; self.tableView.alpha = 0.0f; self.currentSort = 0; [self initNavigationView]; [self initComponents]; [SVProgressHUD show]; self.count = 5; long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [g_server getAllQuestions:salt andToView:self]; if([self.ifAnswer isEqualToString:@"NO"]) { UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您已完成今日答题" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show]; } } #pragma mark --- 提交 -(void)postButtonClicked:(UIButton *)sender { //_saveSelectIndexArr; if (_dataArr333.count==10) { [SVProgressHUD setMaximumDismissTimeInterval:2]; [SVProgressHUD showErrorWithStatus:@"已经完成所有答题"]; NSMutableArray * mutableArray = [[NSMutableArray alloc]initWithCapacity:0]; [_dataArr333 enumerateObjectsUsingBlock:^(QustionJX * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { NSDictionary * dictionary = @{@"questionId":[NSString stringWithFormat:@"%@",obj.id],@"optionId":@"1"}; [mutableArray addObject:dictionary]; }]; long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; NSArray * postArray = mutableArray.copy; NSError *parseError = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postArray options:NSJSONWritingPrettyPrinted error:&parseError]; NSString *jsonstr =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; [SVProgressHUD show]; [g_server postQuestionAnswers:salt andOptions:jsonstr andToView:self]; }else{ UIAlertView * aler = [[UIAlertView alloc]initWithTitle:@"提示" message:[NSString stringWithFormat:@"您有题目没有答完,请返回检查"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [aler show]; self.aler=aler; } if([self.ifAnswer isEqualToString:@"NO"]) { [SVProgressHUD setMaximumDismissTimeInterval:2]; [SVProgressHUD showErrorWithStatus:@"已经完成所有答题"]; } else { NSMutableArray * mutableArray = [[NSMutableArray alloc]initWithCapacity:0]; for(NSDictionary * dict in _questionArray) { NSString * lastAnswer = [NSString stringWithFormat:@"%@",[dict objectForKey:@"answerid"]]; if(lastAnswer != nil && lastAnswer.length != 0 && ![lastAnswer isEqualToString:@"(null)"] && ![lastAnswer isEqualToString:@""]) { NSDictionary * dictionary = [[NSDictionary alloc]initWithObjectsAndKeys:[NSString stringWithFormat:@"%@",[dict objectForKey:@"id"]],@"questionId",lastAnswer,@"optionId", nil]; [mutableArray addObject:dictionary]; long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; NSArray * postArray = mutableArray.copy; NSError *parseError = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postArray options:NSJSONWritingPrettyPrinted error:&parseError]; NSString *jsonstr =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; [SVProgressHUD show]; [g_server postQuestionAnswers:salt andOptions:jsonstr andToView:self]; } else { UIAlertView * aler = [[UIAlertView alloc]initWithTitle:@"提示" message:[NSString stringWithFormat:@"您有题目没有答完,请返回检查"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [aler show]; self.aler=aler; break; } } } } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return _dataArr.count; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSArray * options = [_currentQuestion objectForKey:@"options"]; if (_firstArr.count==0) { return 0; }else{ QustionJX *optionArr = _firstArr[section]; return optionArr.options.count; } } #pragma mark --- 代理 tableView -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //NSArray * options = [_currentQuestion objectForKey:@"options"]; JXQuestionCell * cell = [JXQuestionCell cellWithTableView:tableView]; QustionJX *optionArr = [_firstArr firstObject]; OptionsJX *model=optionArr.options[indexPath.row]; [cell createUI:model andDui:_indexRightRow andSelect:_indexRow andCell:indexPath.row]; NSArray * options = [_currentQuestion objectForKey:@"options"]; NSDictionary * dictionary = [options objectAtIndex:[indexPath row]]; NSString * lastAnswer = [NSString stringWithFormat:@"%@",[_currentQuestion objectForKey:@"answerid"]]; if(lastAnswer != nil && lastAnswer.length != 0 && ![lastAnswer isEqualToString:@"(null)"] && ![lastAnswer isEqualToString:@""]) { NSString * currentAnswerID = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"id"]]; if(currentAnswerID.intValue == lastAnswer.intValue) { NSString * ifRight = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"right"]]; if(ifRight.boolValue) { } } cell.userInteractionEnabled = NO; } else { cell.userInteractionEnabled = YES; } return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 40.0f; } #pragma mark --- 代理。did -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { QustionJX *optionArr = [_firstArr firstObject]; __block OptionsJX *model=nil; _indexRow=indexPath.row; [optionArr.options enumerateObjectsUsingBlock:^(OptionsJX *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ( [obj.right isEqualToString:@"1"]) { _indexRightRow=idx; model=obj; *stop=YES; } }]; __block QustionJX *modelS=nil; [_questionArr enumerateObjectsUsingBlock:^(QustionJX * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { // if ([obj.sort intValue]==_currentSort) { if ([obj.title isEqualToString:self.questionTitle.text]) { modelS=obj; } }]; [_saveSelectIndexArr enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { QustionJX *modeljx=obj[@"option"]; if ([modeljx.title isEqualToString:modelS.title] && [obj[@"checkNo"] intValue]==1) { self.questionTable.userInteractionEnabled=NO; _isclick=YES; *stop=YES; }else{ _isclick=NO; self.questionTable.userInteractionEnabled=YES; } }]; if (_isclick==YES) { return; } _isCheck=1; NSDictionary *dict=@{@"option":modelS,@"title":modelS.title,@"selectIndex":[NSString stringWithFormat:@"%zd",indexPath.row] ,@"rightRow":[NSString stringWithFormat:@"%zd",_indexRightRow],@"checkNo":[NSString stringWithFormat:@"%d",_isCheck],@"currentSort":[NSString stringWithFormat:@"%lu",(unsigned long)_currentSort]}; [_saveSelectIndexArr addObject:dict]; self.questionTitle.text = modelS.title ; [_dataArr333 addObject:modelS]; if (_indexRightRow==indexPath.row) { [_dataArr222 addObject:modelS]; } [_questionTable reloadData]; } -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{ // [_wait hide]; [SVProgressHUD dismiss]; if([aDownload.action isEqualToString:act_GetQuestionAndRules]) { NSDictionary * dict0 = [array1 objectAtIndex:0]; NSLog(@"aaa %@",dict0); _questionArr=[QustionJX mj_objectArrayWithKeyValuesArray:dict0[@"questions"]]; _ruleArr=[RulesJX mj_objectArrayWithKeyValuesArray:dict0[@"rules"]]; [_firstArr addObject:[_questionArr firstObject]]; /* [_questionArr enumerateObjectsUsingBlock:^(QustionJX * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if (idx==0) { [_firstArr addObject:obj]; } }];*/ _dataArr=[packageRoolModel mj_objectArrayWithKeyValuesArray:array1]; QustionJX *modell=[_firstArr firstObject]; self.questionTitle.text = modell.title; [self.questionTable reloadData]; [[NSNotificationCenter defaultCenter]postNotificationName:@"refreshes" object:nil]; }if([aDownload.action isEqualToString:act_PostQuestionAnswers]) { UIAlertView * aler = [[UIAlertView alloc]initWithTitle:@"提示" message:[NSString stringWithFormat:@"您答对了%zd",_dataArr222.count] delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil]; aler.tag=3000; [aler show]; } } -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{ NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]; if([errorCode isEqualToString:@"权限验证失败"]) { if([aDownload.action isEqualToString:act_GetQuestionAndRules]) { long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [g_server getAllQuestions:salt andToView:self]; } if([aDownload.action isEqualToString:act_PostQuestionAnswers]) { if([self.ifAnswer isEqualToString:@"NO"]) { [SVProgressHUD setMaximumDismissTimeInterval:2]; [SVProgressHUD showErrorWithStatus:@"已经完成所有答题"]; } else { NSMutableArray * mutableArray = [[NSMutableArray alloc]initWithCapacity:0]; for(NSDictionary * dict in self.questionArray) { NSString * lastAnswer = [NSString stringWithFormat:@"%@",[dict objectForKey:@"answerid"]]; if(lastAnswer != nil && lastAnswer.length != 0 && ![lastAnswer isEqualToString:@"(null)"] && ![lastAnswer isEqualToString:@""]) { NSDictionary * dictionary = [[NSDictionary alloc]initWithObjectsAndKeys:[NSString stringWithFormat:@"%@",[dict objectForKey:@"id"]],@"questionId",lastAnswer,@"optionId", nil]; [mutableArray addObject:dictionary]; } else { UIAlertView * aler = [[UIAlertView alloc]initWithTitle:@"提示" message:[NSString stringWithFormat:@"您有题目没有答完,请返回检查"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [aler show]; break; } } long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; NSArray * postArray = mutableArray.copy; NSError *parseError = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postArray options:NSJSONWritingPrettyPrinted error:&parseError]; NSString *jsonstr =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; [g_server postQuestionAnswers:salt andOptions:jsonstr andToView:self]; } } } else { [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]]; } if( [aDownload.action isEqualToString:act_UserLogout] ){ //[self performSelector:@selector(doSwitch) withObject:nil afterDelay:1]; } return hide_error; } -(void)backButtonClicked:(UIButton *)sender { [g_navigation dismissViewController:self animated:YES]; } -(void)initNavigationView { self.navigationView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT>=812?88:64)]; self.navigationView.backgroundColor = [UIColor whiteColor]; [self.view addSubview:self.navigationView]; UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 40, JX_SCREEN_WIDTH, 40)]; titleLabel.text = @"每日答题"; titleLabel.textColor = [UIColor blackColor]; titleLabel.font = [UIFont systemFontOfSize:18.0f]; titleLabel.textAlignment = NSTextAlignmentCenter; [self.navigationView addSubview:titleLabel]; self.backButton = [UIButton buttonWithType:UIButtonTypeCustom]; self.backButton.frame = CGRectMake(15, 30, 30, 30); if(JX_SCREEN_HEIGHT >= 812) { self.backButton.frame = CGRectMake(15, 45, 30, 30); } [self.backButton setImage:[UIImage imageNamed:@"title_back_black"] forState:UIControlStateNormal]; [self.backButton addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; [self.navigationView addSubview:self.backButton]; } -(void)initComponents { self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, self.navigationView.frame.origin.y + self.navigationView.frame.size.height, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT - (self.navigationView.frame.origin.y + self.navigationView.frame.size.height))]; self.scrollView.backgroundColor = self.view.backgroundColor; self.scrollView.contentSize = CGSizeMake(JX_SCREEN_WIDTH, self.scrollView.frame.size.height); [self.view addSubview:self.scrollView]; UIImageView * backView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 0.68*JX_SCREEN_WIDTH)]; backView.image = [UIImage imageNamed:@"questionBacks"]; [self.scrollView addSubview:backView]; backView.userInteractionEnabled = YES; UIButton * postButton = [UIButton buttonWithType:UIButtonTypeCustom]; postButton.frame = CGRectMake(JX_SCREEN_WIDTH - 70 - 15, backView.frame.size.height - 30, 70, 30); [postButton setBackgroundColor:[UIColor colorWithRed:253/255.0f green:219/255.0f blue:173/255.0f alpha:1.0f]]; [postButton setTitle:@"提交" forState:UIControlStateNormal]; [postButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [postButton.titleLabel setFont:[UIFont systemFontOfSize:13.0f]]; [postButton.layer setCornerRadius:5.0f]; [postButton.layer setMasksToBounds:YES]; [postButton addTarget:self action:@selector(postButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; [backView addSubview:postButton]; // if(!self.ifAnswer.boolValue) // { // postButton.userInteractionEnabled = NO; // } // else // { // postButton.userInteractionEnabled = YES; // } UIImageView * questionView = [[UIImageView alloc]initWithFrame:CGRectMake(10, backView.frame.origin.y + backView.frame.size.height + 15, JX_SCREEN_WIDTH - 20, 0.84*(JX_SCREEN_WIDTH-20-40))]; questionView.image = [UIImage imageNamed:@"questionImage"]; [self.scrollView addSubview:questionView]; questionView.userInteractionEnabled = YES; self.questionTitle = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, questionView.frame.size.width, 40)]; self.questionTitle.text = @""; self.questionTitle.textColor = [UIColor colorWithRed:115/255.0f green:20/255.0f blue:5/255.0f alpha:1.0f]; self.questionTitle.font = [UIFont boldSystemFontOfSize:15.0f]; self.questionTitle.textAlignment = NSTextAlignmentCenter; [questionView addSubview:self.questionTitle]; self.questionLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 40, questionView.frame.size.width - 30, 40)]; self.questionLabel.text = @""; self.questionLabel.numberOfLines = 0; self.questionLabel.textColor = self.questionTitle.textColor; self.questionLabel.font = [UIFont systemFontOfSize:15.0f]; [questionView addSubview:self.questionLabel]; self.questionTable = [[UITableView alloc]initWithFrame:CGRectMake(0, self.questionLabel.frame.origin.y + self.questionLabel.frame.size.height, questionView.frame.size.width, questionView.frame.size.height - (self.questionLabel.frame.origin.y + self.questionLabel.frame.size.height)) style:UITableViewStylePlain]; self.questionTable.dataSource = self; self.questionTable.delegate = self; self.questionTable.separatorStyle = UITableViewCellSeparatorStyleNone; self.questionTable.backgroundColor = [UIColor clearColor]; [questionView addSubview:self.questionTable]; if([self.ifAnswer isEqualToString:@"NO"]) { self.questionTable.userInteractionEnabled = NO; } else { self.questionTable.userInteractionEnabled = YES; } UIButton * preButton = [UIButton buttonWithType:UIButtonTypeCustom]; preButton.frame = CGRectMake(JX_SCREEN_WIDTH/2 - 80 - 50, questionView.frame.origin.y + questionView.frame.size.height + 15, 80, 30); [preButton setBackgroundColor:[UIColor colorWithRed:253/255.0f green:219/255.0f blue:173/255.0f alpha:1.0f]]; [preButton setTitle:@"上一题" forState:UIControlStateNormal]; [preButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [preButton.titleLabel setFont:[UIFont systemFontOfSize:13.0f]]; [preButton.layer setCornerRadius:5.0f]; [preButton.layer setMasksToBounds:YES]; [preButton addTarget:self action:@selector(preButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; preButton.alpha =1.0f; [self.scrollView addSubview:preButton]; UIButton * nextButton = [UIButton buttonWithType:UIButtonTypeCustom]; nextButton.frame = CGRectMake(JX_SCREEN_WIDTH/2 + 50, preButton.frame.origin.y, 80, 30); [nextButton setBackgroundColor:[UIColor colorWithRed:253/255.0f green:219/255.0f blue:173/255.0f alpha:1.0f]]; [nextButton setTitle:@"下一题" forState:UIControlStateNormal]; [nextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [nextButton.titleLabel setFont:[UIFont systemFontOfSize:13.0f]]; [nextButton.layer setCornerRadius:5.0f]; [nextButton.layer setMasksToBounds:YES]; [nextButton addTarget:self action:@selector(nextButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; nextButton.alpha = 1.0f; [self.scrollView addSubview:nextButton]; self.scrollView.contentSize = CGSizeMake(JX_SCREEN_WIDTH, preButton.frame.origin.y + preButton.frame.size.height + 20); } -(void)nextButtonClicked:(UIButton *)sender { _currentSort ++; if (_currentSort>_questionArr.count-1) { _currentSort=(int)_questionArr.count; UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"当前已是最后一题了" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show]; return; } self.questionTable.userInteractionEnabled=YES; [_firstArr removeAllObjects]; _indexRow=100; _indexRightRow=100; [_questionArr enumerateObjectsUsingBlock:^(QustionJX * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { //if ([obj.sort intValue]==_currentSort) { if ( _currentSort == idx) { [_firstArr addObject:obj]; self.questionTitle.text = obj.title; } }]; [_saveSelectIndexArr enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { QustionJX *modelJx=obj[@"option"]; //if (( [modelJx.title isEqualToString:self.questionTitle.text])&& obj[@"option"]!=nil) { if (( [modelJx.title isEqualToString:self.questionTitle.text])&& obj[@"option"]!=nil) { _indexRightRow=[obj[@"rightRow"] intValue]; _indexRow=[obj[@"selectIndex"] intValue]; } if ( _currentSort == idx) { _indexRightRow=idx; _indexRow=idx; } }]; [self.questionTable reloadData]; } /** 上一题*/ -(void)preButtonClicked:(UIButton *)sender { self.questionTable.userInteractionEnabled=YES; if(_currentSort > 0) { self.currentSort --; [_firstArr removeAllObjects]; _indexRightRow=100; _indexRow=100; [_questionArr enumerateObjectsUsingBlock:^(QustionJX * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { // if ([obj.sort intValue]==_currentSort) { if (_currentSort ==idx) { [_firstArr addObject:obj]; self.questionTitle.text = obj.title; } }]; NSMutableArray *temp=[NSMutableArray array]; [_saveSelectIndexArr enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { NSLog(@"%@",obj); // if (([obj[@"currentSort"] intValue]==_currentSort) QustionJX *modelJx=obj[@"option"]; if (( [modelJx.title isEqualToString:self.questionTitle.text])&& obj[@"option"]!=nil) { //self.questionTable.userInteractionEnabled=NO; _indexRightRow=[obj[@"rightRow"] intValue]; _indexRow=[obj[@"selectIndex"] intValue]; [temp addObject:obj[@"option"]]; _firstArr= temp; }else{ self.questionTable.userInteractionEnabled=YES; } }]; [self.questionTable reloadData]; } return; //UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"当前是第一题了" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; // [alert show]; } -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (alertView.tag==3000) { [g_navigation popToViewController:[JXApplyViewController class] animated:YES]; return; } if(alertView.tag == 1000) { if(buttonIndex==0){ return; } [g_navigation popToViewController:[JXApplyViewController class] animated:YES]; } else if(alertView.tag == 10000) { self.currentSort ++; for(NSDictionary * dictionary in self.questionArray) { NSString * questionSort = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"sort"]]; if(questionSort.intValue == self.currentSort) { NSString * questionTitle = [NSString stringWithFormat:@"第%@题:%@",questionSort,[dictionary objectForKey:@"title"]]; NSString * questionDesc = [NSString stringWithFormat:@"%@",[dictionary objectForKey:@"desc"]]; if(questionTitle != nil && questionTitle.length != 0 && ![questionTitle isEqualToString:@"(null)"] && ![questionTitle isEqualToString:@""]) { self.questionTitle.text = questionTitle; } if(questionDesc != nil && questionDesc.length != 0 && ![questionDesc isEqualToString:@"(null)"] && ![questionDesc isEqualToString:@""]) { self.questionLabel.text = questionDesc; } self.currentQuestion = dictionary; break; } } [self.questionTable reloadData]; } } @end