美文网首页Stan iOS9 课程笔记
Stanford_iOS_L06_Multiple MVCs..

Stanford_iOS_L06_Multiple MVCs..

作者: Shaw233 | 来源:发表于2017-01-21 10:46 被阅读0次

^+I ReIdent
http://www.cocoachina.com/ios/20141224/10752.html

Segue

Paste_Image.png
  if let navcon = destinationvc as? UINavigationController {
        destinationvc = navcon.visibleViewController ?? destinationvc
    }
//the botttom navcon , it`s visibleView is Face


ViewController Lifecycle

What then?

  1. Preparation if being segued to.
  1. Outlet Setting.
  2. Appearing and disappearing
  3. Geometry changes.
  4. Low-memory situations.

After instantiation and outlet-setting, viewDidLoad is called

this is an exceptionally good place to put a lot of setup code
Its better than an init because your outlets are all set up by the time this is called.

   override func viewDidLoad(){ 
        super.viewDidLoad()  // always let super have a chance in lifecycle methods
        //do some setup of my MVC
    }

One thing u may well want to do here is update ur UI from ur Model.
Because now u know all of ur outlets are set

BUT, geometry of ur View is not set yet.

Just before ur view appears on screen, u get notified

 func viewWillappear( animated: Bool) // animated is whether u are appearing 
Paste_Image.png

And u get notified when u will disappear off screen too

This is where u put "remember what`s going on " and cleanup code.

 override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated) // call super in all the ViewWill/Did methods
//do some cleanup now that we`ve been removed form the screen
// but be careful not to do anything time-consuming here, or app will be sluggish
// maybe even kick off a thread to do stuff here(again, we`ll cover threads later
}

There is a "did" version of this too

  func viewDidDisappear(animated: Bool)

Geometry changed?

=W=.png

Autorotation

ddd

Summary

Demo

相关文章

网友评论

    本文标题:Stanford_iOS_L06_Multiple MVCs..

    本文链接:https://www.haomeiwen.com/subject/vyewbttx.html