-
iOS) Custom Present 이용시 ViewContoller Life Cycle 문제iOS 2021. 1. 6. 15:46
기존 modalPresentaionStyle을 통해 presentation 방식을 지정했던 것과 다르게 UIPresentaionController를 사용하여 custom presentatin을 진행하는 경우 따로 설정을 해주지 않는 한 ViewController가 메모리에서 제거되지 않는 것으로 보인다.
아니 메모리에서 제거 되는 것이 아닌 viewDidDisappear메서드가 불리지 않는다.
이는 transition과정에서 매우 문제가 되며 present transition에선 영향이 없지만 dismiss transition에선 transitionContext.viewController(keyType:) 메소드를 통해 containerView에 추가하고 호출할 때, 메모리에서 사라지지 않았던 VC의 view를 다른 View에서 빼앗아가는 거기 때문에 기존 VC에서 view가 사라져 dismiss transition이 비정상적으로 작동되게 만든다.
VC의 lifeCycle을 정상적으로 작동 시키기 위해선 다음 프로퍼티를 Presentation Controller에 오버 라이딩해주면 된다.
The default implementation of this method returns false. If you implement a presentation that does not cover the presenting view controller’s content entirely, override this method and return false.
If you override this method, do not call super.
'iOS' 카테고리의 다른 글
iOS) Core Data (2) - Managed Object와 Managed Object Context (0) 2021.01.26 iOS) Core Data (1) - over view (0) 2021.01.25 iOS) Appstore Transition 따라하기(2) - Present Transition (2) 2021.01.05 iOS) Appstore Transition 따라하기(1) - 기본 구성 (0) 2020.12.02 iOS) Singleton View와 viewController (feat. programmers iOS 실력체크) (0) 2020.10.24