Reputation: 35
I've been making an app that I need help with. After I do what I want the app to do, it goes to a new page. when I press the go back button, it is still in the same state as when I left. I want the first view to completely reset when I hit the button. Any suggestions as to how to do this? Any help is appreciated!
Here is code for what the button currently does:
- (IBAction)retry:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
}
Upvotes: 2
Views: 744
Reputation: 27597
Implement viewWillAppear on your initially displayed viewController as following:
- (void)viewWillAppear:(BOOL)animated
{
//
//put your code to reset this viewController into its initial state here
//
[self resetAllStatesBackToDefault];
}
As an example, suppose you got a UITextField
on that first viewController that is named textField
;
- (void)resetAllStatesBackToDefault
{
self.textField.text = @"";
}
Upvotes: 2