I am working on a “Guess my Number” game in Objective-C, and the problem I am currently having is that once the player runs out of guesses, the submit button is still clickable and causes the output label to have issues. Here is the action the submit button performs.
- (IBAction)userSubmit:(id)sender {
turns = turns--
if (textField.text.intValue == num && turns !=0)
consoleOutput.text = (@"You win!");
else if (textField.text.intValue > num && turns !=0)
consoleOutput.text = (@"Too high!");
else if (textField.text.intValue < num) && turns !=0)
consoleOutput.text = (@"Too low!");
if (turns == 0)
consoleOutput.text = @"You lose!";
}
Is there any additional code I can add to the
if (turns == 0)
consoleOutput.text = @"You lose!";
}
To cause the submit button to “gray out”?
You just need to disable the button: