Nate Uni
Nate Uni

Reputation: 943

How to reset iPhone view as if I was entering it for the first time

I have made a Tic Tac Toe game. Everything is working fine, except that when the game is finished I am unable to reset the view to it's original state (without popping the view of the navigation stack and popping a new one back on). I have reset the model, but how do I then reset the view?

People are pretty on the ball here, so I thought I would come ask here.

Regards, Nate

Upvotes: 0

Views: 307

Answers (2)

Cesar
Cesar

Reputation: 4427

without code the only idea that i had it's you don't release properly the view that you present and dismiss and this means that the init method it's called just once and the controller it's never deallocated.

Modal:

#include 'gameViewController'
...
//Present
game *gameViewController = [[game alloc] init];
gameViewController.delegate = self;
[self presentModalViewController:gameViewController animated:YES];
[gameViewController release];
...
//Dismiss
[self dismissModalViewControllerAnimated:YES];

Navigation Controller:

#include 'gameViewController'
...
//Present
game *gameViewController = [[game alloc] init];
gameViewController.delegate = self;
[self.navigationController pushViewController:gameViewController animated:YES];
[gameViewController release];
...
//Dismiss
[self.navigationController popViewController:YES];

if you are using a tab bar and option could be to move all the game-reset instruction in the method viewWillAppear: instead on viewDidLoad.
If you add come code i can be more specific.

Upvotes: 0

Joshua Nozzi
Joshua Nozzi

Reputation: 61228

How do you set its state initially? You created it so you're more qualified than anyone else to know how to reset it. If it always draws the state of its model correctly, then how about flagging it for display after resetting its model?

Without posting your view's code, it's impossible to say what the problem is without wild guesses.

Upvotes: 1

Related Questions