0

有沒有人有任何想法,這不在iOS8自定義翻轉動畫,但在iOS7。UIViewController在iOS8中的自定義轉換

在iOS8中,我只看到沒有動畫的視圖,但是當視圖被解除時 我確實得到了自定義翻轉過渡。它就像它在呈現時忘記動畫一樣,但當它被解散時它會記住。

任何幫助將不勝感激它驅使我堅果。

- (void) animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext { 

    UIView *containerView = [transitionContext containerView]; 

    UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 
    [containerView addSubview:fromVC.view]; 

    UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 
    [containerView addSubview:toVC.view]; 

    UIViewAnimationOptions animationOption = ([toVC.presentedViewController isEqual:fromVC])?UIViewAnimationOptionTransitionFlipFromLeft:UIViewAnimationOptionTransitionFlipFromRight; 

    if ([toVC class] == [ClockViewController class]) { 

     [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; 

    } 

    [UIView transitionFromView:fromVC.view 
         toView:toVC.view 
         duration:0.7f 
         options:animationOption 
        completion:^(BOOL finished){ 
         [transitionContext completeTransition:YES]; 
        }]; 

} 

回答

0

找出解決方案,以防萬一任何人有同樣的問題。

新增[CATransaction commit];過渡之前,現在它的工作。

  • (無效)animateTransition:(ID)transitionContext {

    的UIView * containerView = [transitionContext containerView];我們可以使用UIViewController * fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];我們可以使用UIViewController來實現這個功能。 [containerView addSubview:fromVC.view];我們可以使用UIViewController * toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];我們可以使用UIViewController來創建一個UIViewController對象。 [containerView addSubview:toVC.view];

    UIViewAnimationOptions animationOption =([toVC.presentedViewController isEqual:方法fromVC])UIViewAnimationOptionTransitionFlipFromLeft:UIViewAnimationOptionTransitionFlipFromRight;

    [CATransaction commit];

    [UIView的transitionFromView:fromVC.view toView:toVC.view 持續時間:0.7F 選項:animationOption 完成:^(BOOL完成){ [transitionContext completeTransition:YES]; }];

}

相關問題