I get this error whenever I try to move from one of my View Controllers to the other one manually (i.e. not with the control + drag on button method):

Warning: Attempt to present <GameOver: 0xd092ed0> on <Game: 0xbb88a50> whose 
view is not in the window hierarchy!

Here is how I'm ending the game and going to the game over page:

- (void)endGame{
    [self performSelector:@selector(goToGameOverScreen) withObject:nil afterDelay:0.4];

- (void)goToGameOverScreen{
    UIViewController *second = [self.storyboard instantiateViewControllerWithIdentifier:@"gameOverPage"];
    second.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self dismissViewControllerAnimated:YES completion:^{
        [self presentViewController:second animated:YES completion:NULL];

There's also some code in the endGame method that ends all of the NSTimers (I didn't include it because it's kinda long).


I kinda figured out what the problem is. when this get completed: [self dismissViewControllerAnimated:YES completion:^{, it goes to the main page (the main menu page). I need to find a way to make it so that it goes to the Game Over page instead.

Related posts

Recent Viewed