Life is a cycle

  • viewDidLoad*viewWillAppear
  • viewDidAppear
  • viewWillDisappear
  • viewDidDisappear
  • viewDidUnload

We are not gonna jump out of it.

  • loadView[1]
  • viewDidLoad[1]
  • viewWillAppear
  • viewWillLayoutSubviews [2]

    Called to notify the view controller that its view is about to
    layout its subviews.

  • viewDidLayoutSubviews[2]

We repeat it and keep making repairs.

图片 1uiviewcontroller_lifecycle

To squeeze the time into one surface. Find the dots next to us,where our
parents looks as young as we are.

  • viewDidAppear
  • viewWillLayoutSubviews
  • viewDidLayoutSubviews
  • viewWillDisappear
  • viewDidDisappear
  • viewDidUnload

© 本文版权归小编 
戒不掉欢畅的本人
 全部,任何款式转发请联系作者。

一生在讲ViewController的生命周期时,我们只大多只关心之下几个主意:

And we’ll finally find the answers,

  1. If you manually nil out your view during didReceiveMemoryWarning,
    loadView and viewDidLoad will be called again. That is, by
    default loadView and viewDidLoad only gets called once per view
    controller instance. ↩ ↩

  2. May be called an additional 0 or more times
    .viewWillLayoutSubviews and viewDidLayoutSubviews will also be
    called at other times when subviews of the main view are loaded, for
    example when cells of a table view or collection view are loaded. ↩

实际ViewController的生命周期如下:

Called to notify the view controller that its view has just laid out
its subviews.

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图