^+I ReIdent
http://www.cocoachina.com/ios/20141224/10752.html
Segue
if let navcon = destinationvc as? UINavigationController {
destinationvc = navcon.visibleViewController ?? destinationvc
}
//the botttom navcon , it`s visibleView is Face
ViewController Lifecycle
What then?
- Preparation if being segued to.
- Outlet Setting.
- Appearing and disappearing
- Geometry changes.
- 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
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)