简体   繁体   中英

Does every time I modal from a vie to another view the method viewdidload gets called?

I'm trying to figure out something about the view controller lifecycle, i understand that viewdidload gets called only once.

BUT, I have a situation were i have 2 view controllers, one is the main view controller and another table view controller.

In the main view controller i have 2 buttons, one for the table view and one to some other view.

The main vorw conrtoller viewdidload does happends once but, Whenever i modal to those other view controllers viewdidload gets call each time.

Im using [self presentviewcontroller: self.navigationcpntroller animated:yes completion: nil]

To modal to the other view controllers from my main view controller. And im using nibs.

What am i not understanding here :/ Tnx

viewDidLoad is called for a view controller the first time the view controller's view has been loaded in the view controller's lifecycle.

If you create a new instance of a view controller each time it is presented then you will see viewDidLoad being called once each time it is presented.

If you create a view controller instance and reuse that same instance over and over, then viewDidLoad is only called once (the first time it is presented).

Since it is normal to create new view controller instances each time you need it, viewDidLoad will be called each time you present it.

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