I have 3 buttons, 1 displays the correct answer and the other two display two random incorrect answer. I also have 10 buttons, with images attached displayed.
I want to associate the images with the button output.. (i.e) if the questons is: 1 x 1, at the moment the only image output I have is the correctanswer. Not two random answers
Display 1 apple (imagebutton) & (correctAnswerButton)
-Display 2 apple (display 2 imagebuttons) & (incorrectAnswerButton)
- Display 3 apple & (display 3 imagebuttons) (incorrectAnswerButton)
From the code I have already is there anyway to link both? Thanks (code below)
NSString *levelString = [NSString stringWithFormat: @"%i", level];
NSString *multipleString = [NSString stringWithFormat: @"%i", _levelStep];
//The levelString loads image file
NSString *imageName = [NSString stringWithFormat: @"%@.jpg", levelString];
UIImage *levelImage = [UIImage imageNamed:imageName];
[currentLevel setImage:levelImage forState:UIControlStateNormal];
//if levelstep is (1 x number) load appropriate levelImage and show multipliers
if (_levelStep == 1) {
[multiplier10 setImage:levelImage forState:UIControlStateNormal];
multiplier10.hidden = NO;
[ans1button1 setImage:levelImage forState:UIControlStateNormal];
ans1button1.hidden = NO;
[ans2button1 setImage:levelImage forState:UIControlStateNormal];
ans2button1.hidden = NO;
[ans3button1 setImage:levelImage forState:UIControlStateNormal];
ans3button1.hidden = NO;
//Through 'til ans1button10,ans2button10,ans3button10 etc...
int rightAnswer = level * _levelStep;
int randomNumber = arc4random_uniform(30);
int randomNumber2 = arc4random_uniform(30);
//Answer Button
[AnswerButton setTitle: [NSString stringWithFormat:@"%i", ((int)rightAnswer)] forState:UIControlStateNormal];
[AnswerButton addTarget:self action:@selector(Change:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:AnswerButton];
[randomButton setTitle: [NSString stringWithFormat:@"%i", ((int)randomNumber)] forState:UIControlStateNormal];
[randomButton addTarget:self action:@selector(Change:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:randomButton];
//Same method for random answer 2..
Please help me find a solution to this annoying problem!! :(
Aucun commentaire:
Enregistrer un commentaire