Scene은 iOS 13부터 도입됨

Inactive-Active 의 절차를 밟음Inactive-Background의 절차를 밟음모든 scene은 독립적이다.
AppDelegate 가 모두 처리AppDelegate에서 처리SceneDelegate에서 처리DidBecomeActive, WillResignActive, DidEnterBackground, WillEnterForeground// MARK: UISceneSession Lifecycle
// 새로운 scene을 만들때 마다 호출. scene Customizing 부분
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene ConnectionOptions) -> UISceneConfiguration{
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
name: "Default Configuration"은 Info.plist 파일의 Application Scene Manifest 하단 분류의 Configuration Name 부분의 값과 일치해야 한다.func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>){
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
// scene이 생성되고 나서 앱과 연결되기 직전 호출.
// scene마다 별도의 초기화가 필요하다면 여기에서 구현
func scene(_ :willConnectTo:)
// release(앱과 연결이 끊어지기) 직전에 호출
// scene이 background에 들어간 직후, 혹은 session이 버려질 때 호출
// scene에 대한 id, scene에 대한 상세정보가 들어가므로 나중에 데이터를 복구할 때 필요한 데이터나 리소스가 필요하다면 여기서 구현
func sceneDidDisconnect(_ scene:)
//inactive->active 직후 호출
func sceneDidBecomeAcitve(_ scene:)
//active -> inactive 직전 호출
func sceneWillResignActive(_ scene:)
//background->foreground 직전, 즉 UI 표시 직전호출
func sceneWillEnterForeground(_ scene:)
//foreground->background 직후 호출
func sceneDidEnterBackground(_ scene:)
application(_:willFinishLaunchingWithOptions:)
application(_:didFinishLaunchingWithOptions:)
application(_:configurationForConnecting:options:)
scene(_:willConnectTo:options:)
sceneWillEnterForeground(_:)
sceneDidBecomeActive(_:)
//이후 홈 화면으로 갈 경우
sceneWillResignActive(_:)
sceneDidEnterBackground(_:)
//다시 앱을 실행
sceneWillEnterForeground(_:)
sceneDidBecomeActive(_:)
//앱스위처로 종료
sceneWillResignActive(_:)
sceneDidEnterBackground(_:)
sceneDidDisconnect(_:)
application(_:didDiscardSceneSessions:)
applicationWillTerminate(_:)
기본적으로 scene을 지원하고 있지만, 다중 윈도우는 기본적으로 설정되어있지 않다.
이를 설정하려면 Info파일에서 Enable Multiple Windows를 Yes로 바꾸어주면 된다.
스플릿 뷰를 위해 앱의 화면이 잠깐 옆으로 빠질때에는 inactive 상태가 되고, 이후 옆에 열 앱을 선택해주면 바로 active 상태가 된다.
print(self, #function)
해당 함수를 확인하고자 하는 메소드 안에 작성해두고 콘솔창을 확인하면 된다.