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 提示功能 -(IBAction)tipClick {
//1.把答题区中所有的按钮清空 for (UIButton *btn in self.answerView.subviews) { //用代码执行点击答题按钮的操作 [self answerClick:btn]; } //2.把正确答案的第一个字,设置到答题区中 Question *question=self.questions[self.index]; NSString *first=[question.answer substringToIndex:1]; UIButton *btn=[self optionButtonWithTitle:first isHidden:NO]; [self optionClick:btn]; //扣分 [self changeScore:-1000];
} #pragma 分数处理 -(void)changeScore:(int)score { //取出当前的分数 int currentScore=self.scoreButton.currentTitle.intValue; //使用score调整分数 currentScore+=score; //重新设置分数 [self.scoreButton setTitle:[NSString stringWithFormat:@"%d",currentScore] forState:UIControlStateNormal]; }
|