简体   繁体   English

每当我从一个视图到另一个视图进行模态调整时,是否都会调用viewdidload方法?

[英]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. 我试图找出有关视图控制器生命周期的信息,我知道viewdidload仅被调用一次。

BUT, I have a situation were i have 2 view controllers, one is the main view controller and another table view controller. 但是,我的情况是我有2个视图控制器,一个是主视图控制器,另一个是表视图控制器。

In the main view controller i have 2 buttons, one for the table view and one to some other view. 在主视图控制器中,我有2个按钮,一个用于表格视图,另一个用于其他视图。

The main vorw conrtoller viewdidload does happends once but, Whenever i modal to those other view controllers viewdidload gets call each time. 主控制单元viewdidload确实发生过一次,但是,每当我对这些其他视图控制器进行模态化时,viewdidload每次都会被调用。

Im using [self presentviewcontroller: self.navigationcpntroller animated:yes completion: nil] 我正在使用[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 我在这里不明白什么:/ 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. 第一次在视图控制器的生命周期中加载视图控制器的视图时,将为视图控制器调用viewDidLoad

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. 如果您每次创建一个新的视图控制器实例,则将在每次显示时调用一次viewDidLoad

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). 如果创建视图控制器实例并一遍又一遍地重用同一实例,则viewDidLoad仅被调用一次(第一次显示它)。

Since it is normal to create new view controller instances each time you need it, viewDidLoad will be called each time you present it. 由于每次需要时都创建新的视图控制器实例是正常的,因此每次您提供它时都会调用viewDidLoad

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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