user1554681
user1554681

Reputation: 115

ViewDidLoad Method is called again

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?

Upvotes: 3

Views: 1312

Answers (2)

Hossam Ghareeb
Hossam Ghareeb

Reputation: 7123

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

Upvotes: 0

melsam
melsam

Reputation: 4977

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];

Upvotes: 1

Related Questions