简体   繁体   中英

Push View Controller into Navigation Controller

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

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM