Question

I have three viewcontroller. when I get to the third viewcontroller, I use poptorootviewcontroller to pop to my first view controller, but when I use popviewcontroller in my third viewcontroller (i want to go back to my second viewcontroller) its poping but all the info that I edit in my second viewcontroller are there, and I want the secondviewcontroller to be new (reset this viewcontroller), like this viewcontroller to be reloaded. here is my code in the third viewcontroller:

-(IBAction)playAgain:(id)sender
{
   [self.navigationController popViewControllerAnimated:YES];
}

how can I do it? thanks!

Was it helpful?

Solution

In the second viewcontroller, you should write a method viewWillAppear like below,

-(void) viewWillAppear:(BOOL)animated
{
     [super viewWillAppear:animated];
     //set initial values here  
}

This method will call when your controller is about to appear. So while third viewcontroller will get popped, this method will get called and you can reset values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top