In my app project I want to be able to tap a button, wait 5 seconds, and then a UILabel and UIImageView appear. Here’s what I have so far:
- (IBAction)startTimer
{
responseBox.placeholder = @"Message Here";
timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(timerStop) userInfo:nil repeats:YES];
mainInt +=1;
}
- (void)timerStop
{
if (mainInt == 5)
{
[timer invalidate];
titleLabel.hidden = NO;
messageLabel.hidden = NO;
messageLabel.text = @"Message";
image.hidden = NO;
}
}
Everything’s linked correctly, what’s going on?
mainIntis only incremented when you press thestartTimerbutton, so that does you no good intimerStop. Also, if you want to incrementmainIntcorrectly, usemainInt++;Try this: