- - (void)viewDidAppear:(BOOL) animated 该方法通知视图控制器,它的视图已经被加入视图树 Discussion 我们可以重写该方法执行附加任务,实现如何显示出视图。重写必须调用 super 方法。 Note: If a view controller is presented by a view controller inside of a popover, this method is not invoked style="padding:3px 0px; margin:0px; list-style:none; text-indent:80px"> 该方法通知视图控制器,它的视图已经被加入视图树
- 1) ViewDidLoad - 需要的视图元素都在此方法加载
- 2) ViewWillAppear: 这里通常不做视图的修改,而用来更新Form数据,就是给给form重新填入新数据,该页面从别的页面回来时更新。UIView的创建非常费时费力,因此到 viewWillAppear时,iphone已经蓄势待发地、兴冲冲地要去显示了,就不要在这个地方再干费时费力的事情了,纯更新数据就可以了。(I use ViewWillAppear usually just to update the data> 3) ViewDidAppear: 最后,视图已经显示了,那这里可以做一些远程取数据的费时费力的工作。(Finally, I use the ViewDidAppear to start off new threads to things that would take a long time to execute, like for example doing a webservice call to get extra data for the form above.The good thing is that because the view already exists and is being displayed to the user, you can show a nice "Waiting" message to the user while you get the data.)
-
- (void)viewDidLoad
该方法在控制器的视图载入内存时调用
Discussion
该方法在视图控制器(XXXViewController)已经将其视图树(视图里应有的各种东西)(view hierarchy)载入内存后调用。该方法的调用不考虑是否视图树是从nib文件(或storyboard)得来,还是纯代码获得;纯代码
一般使用 loadView 方法,我们一般通过重写 loadView 方法做附加初始化,附加是指基于已有的 nib 文件或 storyboard。
- (void)viewWillAppear:(BOOL)animated
该方法通知视图控制器,它的视图将要(is about to) 被加入到视图树。
Discussion
该方法两个事件之前调用,一个是在视图将要被加入到视图树,二个是任何所需要的动画配置
之前。我们可以重写该方法,实现定制如何显示视图,比如,使用该方法改变状态条(status bar)的方向和样式,以适应该视图启动时的方向和样式。重写该方法必须调用 [super viewWillAppear:animated]。.
For more information about the how views are added to view hierarchies by a view controller, and the sequence of messages that occur, see “Responding to Display-Related Notifications”.
Note: If a view controller is presented by a view controller inside of a popover, this method is not invoked>the presenting view controller after the presented controller is dismissed.
该方法通知视图控制器,它的视图已经被加入视图树
Discussion
我们可以重写该方法执行附加任务,实现如何显示出视图。重写必须调用 super 方法。
Note: If a view controller is presented by a view controller inside of a popover, this method is not invoked on the presenting view controller after the presented controller is dismissed.
viewDIdLoad等方法的详细介绍
最新推荐文章于 2022-09-22 19:37:52 发布