Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I pause the app when an alert appears on the screen?
    text
    copied!<p>I want to pause the screen when an alert is shown on the screen then undo the pause when the alert is dismissed. How would I do that? Here is my view controller:</p> <pre><code>- (void)viewDidLoad {NSLog(@"viewDidLoad"); [super viewDidLoad]; [self generate]; [self.answer becomeFirstResponder]; UIAlertView *alert; {alert = [[UIAlertView alloc] initWithTitle:@"Welcome to iCanMultiply!" message:@"Tap 'Start' to start the game" delegate: self cancelButtonTitle:@"Start" otherButtonTitles: nil]; } [alert show]; [alert release]; alertTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(showAlert) userInfo:nil repeats:YES]; } -(void)showAlert { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Game Over" message:@"You ran out of time" delegate:self cancelButtonTitle:@"Try Again" otherButtonTitles: nil]; [alert show]; [alert release]; } - (IBAction)submit:(id)sender { int num = [answer.text intValue]; UIAlertView *alert; if (num == label.tag) { NSUInteger messageCount = [messagesCorrect count]; int randomMessageIndex = arc4random() % messageCount; alert = [[UIAlertView alloc] initWithTitle:@"Correct!" message:[messagesCorrect objectAtIndex:randomMessageIndex] delegate:self cancelButtonTitle:@"Next Question" otherButtonTitles: nil]; alert.tag = 1; } else { NSUInteger messageCount = [messagesIncorrect count]; int randomMessageIndex = arc4random() % messageCount; alert = [[UIAlertView alloc] initWithTitle:@"Wrong!" message:[messagesIncorrect objectAtIndex:randomMessageIndex] delegate:self cancelButtonTitle:@"Try Again" otherButtonTitles: nil]; } [alert show]; [alert release]; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (alertView.tag == 1) { [self generate]; answer.text = @""; } } -(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { } </code></pre> <p>Please note that my App Delegate is the same as it was when I first started working on the app.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload