J'ai essayé de faire une application iPhone qui affiche deux nombres aléatoires puis vous entrez une réponse, puis appuyez sur Soumettre et il devrait afficher une étiquette qui dit soit Droite ou mauvais mais quand je l'ai écrit le code, il affiche toujours droit Voici le code:Je veux faire un contrôle de vue qui est vraiment un test de table de temps
- (IBAction)but01Pressed:(id)sender{
NSLog(@"B111111");
RandomNum = arc4random() %25;
if (RandomNum == 0) {
RandomNum = arc4random() %25;
if (RandomNum == 0) {
RandomNum = arc4random() %25;
}
}
//@"GLOBAL=%@ %@",appd.globalString, name.text
lab01.textColor = [UIColor blueColor];
lab02.textColor = [UIColor blackColor];
textF01.hidden = NO;
textF02.hidden = NO;
textF03.hidden = NO;
adotime01.hidden = NO;
equal01.hidden = NO;
SubmitFQ01.hidden = NO;
textF01.text = [NSString stringWithFormat:@"%d",RandomNum];
RandomNum = arc4random() %15;
if (RandomNum == 0) {
RandomNum = arc4random() %15;
if (RandomNum == 0) {
RandomNum = arc4random() %15;
}
}
textF02.text = [NSString stringWithFormat:@"%d",RandomNum];
}
`enter code here`- (IBAction)submitbutPressed:(id)sender;
{
if (textF03.text == [NSString stringWithFormat:@"%d",[textF01.text intValue] * [textF02.text intValue]]) {
label066.text = @"Wrong";
label066.hidden = NO;
}
else
{
label066.text = @"Right";
label066.hidden = NO;
}
}
Il semble que vous ayez 'RIGHT' et' WRONG' associé au cas incorrect dans la dernière instruction if ... – darthbith