Reputation: 3058
i have 2 view controllers, VCA
and VCB
. I transition from VCA
to VCB
with presentViewController(VCB, animated: true, completion: nil)
and got back with dismissViewControllerAnimated(true, completion: nil)
in VCB
. This transition is managed by a custom TransitionManager
instance with both VCA
and VCB
having their own TransitionManager
instance as their transitioningDelegate
's.
I want VCB
to be presented over the top of VCA
so in VCB
's initialiser I add:
convenience init() {
self.init()
modalPresentationStyle = .OverFullScreen
}
This works.
However, if I remove modalPresentationStyle = .OverFullScreen
from VCB
's initialiser, and try to set it in the TransitionManager
class in the UIViewControllerAnimatedTransitioning
delegate as follows
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let transitionContext: UIViewControllerContextTransitioning!
let toVC = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
toVC.modalPresentationStyle = .OverFullScreen
// do animation ...
}
the effect doesn't work. Why is this the case, please?
Edit
It seems that modalPresentationStyle.rawValue
is 0 (.FullScreen
) in VCB
's viewDidLoad
and then 5 (the wanted value, OverFullScreen
) in VCB
's viewDidAppear
.
Upvotes: 1
Views: 1469
Reputation: 3058
Apple documentation states To change the transition type, you must set this property before presenting the view controller.
Upvotes: 1