viewDIdLoad等方法的详细介绍

  • - (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”.

    - viewDidLoad 和 - viewWillApear 和 -viewDidAppear

    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.


    - (void)viewDidAppear:(BOOL) animated

    该方法通知视图控制器,它的视图已经被加入视图树

    Discussion

    我们可以重写该方法执行附加任务,实现如何显示出视图。重写必须调用 super 方法。

    - viewDidLoad 和 - viewWillApear 和 -viewDidAppear

    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.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值