ViewController LifeCycle
1. None
// FirstViewController가 보여지는 경우 FirstViewController viewDidLoad() FirstViewController viewWillAppear(_:) FirstViewController viewDidAppear(_:) // FirstViewController -> SecondViewController으로 present SecondViewController viewDidLoad() SecondViewController viewWillAppear(_:) SecondViewController viewDidAppear(_:) // SecondViewController -> FirstViewController으로 dismiss SecondViewController viewWillDisappear(_:) SecondViewController viewDidDisappear(_:) SecondViewController deinit
2. FullScreen
// FirstViewController가 보여지는 경우 FirstViewController viewDidLoad() FirstViewController viewWillAppear(_:) FirstViewController viewDidAppear(_:) // FirstViewController -> SecondViewController으로 present SecondViewController viewDidLoad() FirstViewController viewWillDisappear(_:) SecondViewController viewWillAppear(_:) SecondViewController viewDidAppear(_:) FirstViewController viewDidDisappear(_:) // SecondViewController -> FirstViewController으로 dismiss SecondViewController viewWillDisappear(_:) FirstViewController viewWillAppear(_:) FirstViewController viewDidAppear(_:) SecondViewController viewDidDisappear(_:) SecondViewController deinit
3. OverFullScreen
// FirstViewController가 보여지는 경우 FirstViewController viewDidLoad() FirstViewController viewWillAppear(_:) FirstViewController viewDidAppear(_:) // FirstViewController -> SecondViewController으로 present SecondViewController viewDidLoad() SecondViewController viewWillAppear(_:) SecondViewController viewDidAppear(_:) // SecondViewController -> FirstViewController으로 dismiss SecondViewController viewWillDisappear(_:) SecondViewController viewDidDisappear(_:) SecondViewController deinit
FullScreen vs. OverFullScreen
None | FullScreen | OverFullScreen |
---|---|---|
![]() |
![]() |
![]() |
UIModalPresentationFullScreen
스타일을 사용하여 뷰 컨트롤러를 표시할 때 UIKit은 일반적으로 전환 애니메이션이 완료된 후 기본 뷰 컨트롤러의 뷰를 제거UIModalPresentationOverFullScreen
스타일을 지정하면 해당 보기의 제거를 방지할 수 있음
(Presented 뷰 컨트롤러에 Presenting 뷰 컨트롤러의 콘텐츠가 표시되는 transparent 영역이 있는 경우 해당 스타일을 사용)
viewDidLoad vs. viewWillAppear
- viewDidLoad
- 뷰 컨트롤러가 뷰 계층 구조를 메모리에 로드한 후에 호출됨
- nib파일에서 로드된 뷰에 대한 추가적인 초기화를 수행하거나 스토리보드에 없는 뷰를 추가하고 구성하기
- viewWillAppear
- 뷰 컨트롤러의 뷰가 뷰 계층에 추가되기 직전에 호출됨
- 뷰 컨트롤러가 화면에 나타날 때마다 발생해야 하는 작업들을 수행하기
- ex) 자동 재생이 활성화된 경우 미디어 파일 재생을 시작
- ex) trailCollection 변경으로 인한 레이아웃 재설정
App LifeCycle
// Unattached -> Foreground Inactive AppDelegate application(_:didFinishLaunchingWithOptions:) SceneDelegate scene(_:willConnectTo:options:) FirstViewController viewDidLoad() FirstViewController viewWillAppear(_:) SceneDelegate sceneWillEnterForeground(_:) // Foreground Inactive -> Foreground Active SceneDelegate sceneDidBecomeActive(_:) FirstViewController viewDidAppear(_:) // Foreground Active -> Foreground Inactive SceneDelegate sceneWillResignActive(_:) // Foreground Inactive -> Foreground Active SceneDelegate sceneDidBecomeActive(_:) // Foreground Active -> (Foreground Inactive) -> Background SceneDelegate sceneWillResignActive(_:) SceneDelegate sceneDidEnterBackground(_:) // Background -> (Foreground Inactive) -> Foreground Active SceneDelegate sceneWillEnterForeground(_:) SceneDelegate sceneDidBecomeActive(_:)
Foreground Inactive | Foreground Active |
---|---|
![]() |
![]() |
Foreground Inactive (App Switcher) | Background |
![]() |
![]() |
Foreground Active (incoming phone call) | Background (incoming phone call) |
![]() |
![]() |
Foreground Inactive ↔ Active (Lock screen) | Foreground Inactive (Lock screen) |
![]() |
![]() |
Foreground Inactive ↔ Active (Lock screen - camera) | Background (Lock) |
![]() |
참고
'' 카테고리의 다른 글
Cache (0) | 2022.11.04 |
---|---|
setNeedsLayout() vs. setNeedsDisplay() (0) | 2022.11.03 |
언어 및 지역에 해당하는 문자열 (0) | 2022.10.01 |
[해결방법] reason : The model used to open the store is incompatible with the one used to create the store (0) | 2021.12.25 |
setNeedsLayout vs. layoutIfNeeded (0) | 2021.08.31 |