viewWillAppear/viewDidAppaer and viewWillDisappear/viewDidDisappear
viewWillLayoutSubviews
Lifecycle Methods
1
2
3
4
5
6
7
overridefuncviewDidLoad(){// call super's version at beginning or endsuper.viewDidLoad()// do more setup// update your ui// geometry is not set yet (bounds)}
1
2
3
4
5
funcviewWillAppear(animated:Bool){// every time the view gets displayed// geometry is set (bounds)}funcviewDidAppear(animated:Bool)
1
2
3
4
5
6
overridefuncviewWillDisappear(animated:Bool){super.viewWillDisappear(animated)// clean up stuff// get rid of image}funcviewDidDisappear(animated:Bool)
1
2
3
// your geometry has changed (rotate)funcviewWillLayoutSubviews()funcviewDidLayoutSubviews()