+transitionFromView:toView:duration:options:completion:performs work on processing the hierarchy of views. You do not need [containerView addSubview:toView].
Somewhere inside, +transitionFromView:toView:duration:options:completion:inside should be the following code:
UIView *superview = fromView.superview;
[fromView removeFromSuperview];
[superview addSubview:toView];
You tried to remove the code containerView:
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *toView = toVC.view;
UIView *fromView = fromVC.view;
NSTimeInterval duration = 0.35;
[UIView transitionFromView:fromView toView:toView duration:duration options:(self.reverse?UIViewAnimationOptionTransitionFlipFromLeft:UIViewAnimationOptionTransitionFlipFromRight) |
UIViewAnimationOptionAllowUserInteraction completion:^(BOOL finished) {
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}];
}
source
share