3
votes

I have two View Controller. In the first I do some stuff and then I can push the second View Controller by clicking a button (the button connected with the other ViewController in the storyboard). There I can do some settings and so on. I get back to the first View Controller with the button "Done". But then the ViewDidLoad method is called again and all the "stuff" (text in textfields, ...) is gone.

I hope you guys understand my problem.

Why? And how can I disable this?

2
Please post the code showing how you are moving to second view controller. - iDev
I do this in the storyboard... rigth click on button->drag it to the second ViewController->Style:Modal - user1554681

2 Answers

1
votes

How are you going back to the first view controller from the second one? I think your problem is you're re-instantiating the first view controller when the user hits "Done".

Instead, you should be using either "popViewControllerAnimated" or "dismissViewControllerAnimated" to go back to the first view controller.

e.g: (one of these 2 should work):

[self.navigationController popViewControllerAnimated:YES];
[self dismissViewControllerAnimated:YES completion:nil];
0
votes

Maybe the firstViewController is unLoaded because of receiving memory warning. So when it opened again, it calls ViewDidLoad