그 애매함에 대해
앱스킴이나 푸시를 통해서 앱으로 진입할 때, 앱의 기존 상태는 어떻게 관리해줘야하는가에서 시작되었습니다. 이번에 정리한 브런치 iOS앱의 정책은 에디팅 상태(글, 작가신청)에서 아직 저장되지 않은 수정사항이 있으면, 사용자에게 진행 여부를 묻도록 하고, 그 외의 presentedViewController는 dismiss 후 진행하도록 합니다. 여기까지 정하고 나니 아래의 문제들에 대한 답이 헷갈리기 시작했습니다.
MainViewController - Container
NavigationController - Child of MainViewController
DiscoverViewController - Root of NavigationController
MainViewController.presentedViewController는? - ANavigationController
NavigationController.presentedViewController는? - ANavigationController
NavigationController.topViewController는? - DiscoverViewController
NavigationController.visibleViewController는? - ANavigationController.topViewController
DiscoverViewController.presentedViewController는? - ANavigationViewController
NavigationController를 교체하면 어떻게 되나? - ANavigationViewController는 유지됨. ANavigationViewController를 dismiss 하면 교체된 NavigationController가 나타남.
MainViewController.presentedViewController는? - BNavigationController
NavigationController.presentedViewController는? - BNavigationController
NavigationController.topViewController는? - DiscoverViewController
NavigationController.visibleViewController는? - BNavigationController.topViewController
DiscoverViewController.presentedViewController는? - BNavigationController
NavigationController를 교체하면 어떻게 되나? - BNavigationController는 유지됨. BNavigationController를 dismiss 하면 교체된 NavigationController가 나타남.
MainViewController.presentedViewController는? - BNavigationController
NavigationController.presentedViewController는? - BNavigationController
NavigationController.topViewController는? - DiscoverViewController
NavigationController.visibleViewController는? - CViewController
DiscoverViewController.presentedViewController는? - BNavigationController
BNavigationController.presentedViewController는? - CViewController
BNavigationController.topViewController.presentedViewController는? - CViewController
NavigationController를 교체하면 어떻게 되나? - CViewController, BNavigationController는 유지됨. CViewController를 dismiss하고, BNavigationController를 dismiss하면 교체된 NavigationController가 나타남.
CViewController.presentingViewController는?
중첩된 presentedViewController가 있을 경우 dismiss 처리를 확인하기 위한 실험이었는데 문서에 언급이 있었습니다.
The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, UIKit asks the presenting view controller to handle the dismissal.
If you present several view controllers in succession, thus building a stack of presented view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.
visibleViewController도 마찬가지입니다.
The currently visible view can belong either to the view controller at the top of the navigation stack or to a view controller that was presented modally on top of the navigation controller itself.
좋은 헛수고였습니다. 어리석은 이여.