0

I am pushing and popping from one view to the other within my App. The view is being retained in the memory so when you hit the "Back" button after pushing a view, the same screen that was before you pushed the view is retained.

For some reason, I will need to reload the parent view after popping from a child view. I need to display different content based on the actions the user taken when they were redirected to the child view.

I am using UINavigationController to navigate from one view to the other. I need it so I can easily go back and forth within the different views of the App.

Wassim Taher
  • 966
  • 1
  • 9
  • 26
  • Why not use `viewDidAppear:` to modify the view? The things that you do in `viewDidLoad`, which happens only once, can be done here instead. – Nandeep Mali Oct 25 '12 at 08:42
  • This is a great tip that I wasn't aware of. I am going to try it out later on today and if it works out I will come back and accept your answer. Can you please post this as an answer meanwhile? Thanks! – Wassim Taher Oct 25 '12 at 08:46

1 Answers1

1

The correct way to do this would be to perform your actions in viewDidAppear. Initialisation code that you write in viewDidLoad is called only once. But in viewDidAppear you can refresh your view's content every time the view is added to the window. The controller is retained in the memory for performance reasons. Removing it would hamper that factor.

Here is a stack overflow post that explains the different view* callbacks in good detail.

Community
  • 1
  • 1
Nandeep Mali
  • 4,456
  • 1
  • 25
  • 34