Question

Some times when I push ViewController into Navigation Controller, the viewDidLoad() method of the View Controller is not called. And this cause my application to crash. I would appreciate any help.

I forget to mention that I load the view from the nib before I push it to the Navigation Controller.

Thanks, Sarah

Was it helpful?

Solution

The viewDidLoad method is only called when the view is first loaded from the Nib file. If the view was already loaded and you push the view again it will not fire again. Depending on what you want to do, you may want to use viewWillAppear or viewDidAppear instead.

OTHER TIPS

Once the View is loaded and added to the Controller's stack, you will not see this called again. You would need the view to get popped off the stack and pushed again to see it. You can always be assured viewWillAppear will get invoked everytime you return to the view. This allows you to do any housekeeping that may be in order (which i assume is the goal).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top