3

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!

4

1 回答 1

5

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.

于 2012-07-08T17:11:35.373 回答