【iOS】今更聞けない UIViewControllerのライフサイクル その2 (Swift)
【iOS】今更聞けないUIViewControllerのライフサイクル その2 (Swift)
過去に書いていたのですが、意外と観ていただいている人がいたので、更新版です
忘れやすいですよね
もう少し、細かいイベントを追加しました
表示する時
- awakeFromNib
- loadView
- viewDidLoad
- loadViewIfNeeded
- viewWillAppear
- viewLayoutMarginsDidChange
- viewSafeAreaInsetsDidChange
- updateViewConstraints
- viewIsAppearing
- viewWillLayoutSubviews
- viewDidLayoutSubviews
- viewDidAppear
別ページ表示する時
- viewWillLayoutSubviews
- viewDidLayoutSubviews
- viewWillDisappear
- viewWillLayoutSubviews
- viewDidLayoutSubviews
- viewDidDisappear
import UIKit class ViewController: UIViewController { override func awakeFromNib() { super.awakeFromNib() print("awakeFromNib") } override func loadView() { super.loadView() print("loadView") } override func viewDidLoad() { super.viewDidLoad() print("viewDidLoad") } override func loadViewIfNeeded() { super.loadViewIfNeeded() print("loadViewIfNeeded") } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) print("viewWillAppear") } override func viewLayoutMarginsDidChange() { super.viewLayoutMarginsDidChange() print("viewLayoutMarginsDidChange") } override func viewSafeAreaInsetsDidChange() { super.viewSafeAreaInsetsDidChange() print("viewSafeAreaInsetsDidChange") } override func updateViewConstraints() { super.updateViewConstraints() print("updateViewConstraints") } override func viewIsAppearing(_ animated: Bool) { super.viewIsAppearing(animated) print("viewIsAppearing") } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) print("viewDidAppear") } override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() print("viewWillLayoutSubviews") } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() print("viewDidLayoutSubviews") } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) print("viewWillDisappear") } override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) print("viewDidDisappear") } }
コメント
コメントを投稿