Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 2.04 KB

view-controller-life-cycle.md

File metadata and controls

34 lines (23 loc) · 2.04 KB

View Controller의 Life Cycle

UIViewController 주요 콜백

❓왜 콜백 메소드라 부를까?
: 내가 직접 호출하는 것이 아니라 시스템이 호출하는 것이기 때문

View Controller Life Cycle Image

cf. func loadView(): Creates the view that the controller manages. You override this method only in case you want to build the whole interface for the view controller from code.

  • func viewDidLoad(): Called after the controller's view is loaded into memory.
    • view controller의 lifetime 중 한번만 불림!
    • Usually override this method to perform additional initialization on views.
    • 이 단계에서 view bounds는 아직 최종 결정되지 않음 (viewWillLayoutSubViews에서 결정됨)
  • func viewWillAppear(Bool): Notifies the view controller that its view is about to be added to a view hierarchy.
  • func viewDidAppear(Bool): Notifies the view controller that its view was added to a view hierarchy.
  • func viewWillDisappear(Bool): Notifies the view controller that its view is about to be removed from a view hierarchy.
  • func viewDidDisappear(Bool): Notifies the view controller that its view was removed from a view hierarchy.

뷰가 나타나고, 사라지고라고 표현할 수도 있지만 뷰계층에 추가되고, 뷰계층에서 제거되고라고 표현하면 좀 더 팬시하지 않을까 😇

Valid State Transitions

참고 학습 자료