Container view disappearing on completeTransition:

后端 未结 2 1055
囚心锁ツ
囚心锁ツ 2020-12-24 03:28

I am using custom view controller transitions, UIViewControllerAnimatedTransitioning, to present and dismiss a view controller.

The presenting animation

2条回答
  •  长情又很酷
    2020-12-24 04:10

    My solution is setting modalPresentationStyle = .custom. It can be before or after the line transitioningDelegate = self.

    TLDR:

    This discussion regards to presenting transition only, because I didn't have much issue with dismissing transition.

    My modal view is smaller than the screen and the presenting view is supposed to be shown in the background. But no, I got a totally black background instead of the presenting view as soon as transitionContext.completeTransition is called. I have a similar modal view with the presenting view in the background somewhere else in code, and it's totally working. After doing some comparison I eliminate all the other possibilities and narrow down to the difference of modalPresentationStyle = .custom, which has .fullScreen for the default value. I guess .fullScreen assumes the presented view takes full screen and decide to remove the presenter view (fromView) regardlessly.

    One thing interesting with modalPresentationStyle = .custom: transitionContext.view(forKey: .from) returns nil while transitionContext.viewController(forKey: .from) still returns the presenting view controller.

提交回复
热议问题