1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #pragma mark 答题区按钮解决方法 -(void)answerClick:(UIButton *)button { //1.如果按钮没有字,直接返回 if (button.currentTitle.length==0) { return; } //2.如果有字,清除文字,候选区按钮显示 //2.1使用button的title去查候选区中对应的按钮 UIButton *btn=[self optionButtonWithTitle:button.currentTitle]; //2.2显示对应按钮 btn.hidden=NO; //2.3清除button的文字 [button setTitle:@"" forState:UIControlStateNormal]; //2.4只要点击了按钮上的文字,意味着答题区的内容不完整 [self setAnswerButtonsColor:[UIColor blackColor]];
} -(UIButton *)optionButtonWithTitle:(NSString *)title { //遍历候选区中的所有按钮 for (UIButton *btn in self.optionsView.subviews) { if ([btn.currentTitle isEqualToString:title]&&btn.isHidden) { return btn; } } return nil; }
|