View Controller과 App 생명주기

hankyulee·2022년 9월 22일
0

인터뷰

목록 보기
1/12

View Controller 생명주기

역할: 다른 뷰컨트롤러 등의 객체들과 상호작용 하기, 루트 뷰에 뷰를 추가하여 뷰 레이아웃 관리, 뷰컨간의 이동, 유저 인터렉션 처리.
The view controller that’s owned by the window is the app’s root view controller and its view is sized to fill the window.
To load a view controller from a storyboard, call the instantiateViewController(withIdentifier:)
It’s responsible for creating those views. vc가 release될때 view들 relinquishing.

Viewdidload: 뷰컨트롤러의 뷰가 메모리에 로드 된 후 호출
ViewWillAppear: 뷰가 나타나기 전에
ViewDidAppear: 뷰가 나타난 후
ViewWillDisappear: 뷰가 사라지기 직전
ViewDidDisappear: 뷰가 사라지고난

첫번째 뷰는 네비게이션 컨트롤러의 rootView이기 때문에 갔다가 다시 돌아와도 viewDidLoad가 되지 않는다. 두번째 뷰는 왜 ViewDidLoad가 계속 될까? pop하면 메모리에서 사라지기 때문에 다시 들어오면 메모리에서 로드 되는 것.

loadView: 뷰를 만드는 역할

참고:
https://zeddios.tistory.com/43
https://zeddios.tistory.com/44

앱의 생명주기

When your app’s state changes, UIKit notifies you by calling methods of the appropriate delegate object:

  1. Not running: 앱 실행X, 완전히 종료, 동작X
  2. Foreground : system resources, including the CPU.
  • inactive: 미리 알림, 얼럿, 전화올때, 배터리 부족 메세지 뜰때처럼 이벤트 받지 못하는 상황
  • active:
  1. Background : Suspend상태 전 잠깐 머무는 상태. 코드가 실행중이지만, 이벤트를 받을 수 없음.
  2. suspend: 코드가 실행하지 않는 상태.

ios13 -> sceneDelegate

0개의 댓글