2016-06-14 8 views
1

私は、モーダル表示されたビューコントローラのカスタムトランジションをUIViewControllerTransitioningDelegate,UIViewControllerAnimatedTransitioningおよびUIPresentationControllerを使用して作成しようとしています。私の提示ビューコントローラでpresentationTransitionWillBeginでanimateAlongsideTransitionを使用する場合の問題

私はUIViewControllerTransitioningDelegateを実装し、次の方法があります:

-(id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented 
                   presentingController:(UIViewController *)presenting 
                    sourceController:(UIViewController *)source { 

    return [[MyAnimationController alloc] initWithAnimationType:MyAnimationTypePresent]; 
} 

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed { 
    return [[MyAnimationController alloc] initWithAnimationType:MyAnimationTypeDismiss]; 
} 

- (UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented 
                presentingViewController:(UIViewController *)presenting 
                 sourceViewController:(UIViewController *)source { 

    return [[MyPresentationController alloc] initWithPresentedViewController:presented presentingViewController:presenting]; 
} 

今すぐUIPresentationControllerの私のサブクラスで私が提示ビューコントローラの下に調光ビューを追加し、一緒にして、それをフェードしたい

を外観遷移。

- (void)presentationTransitionWillBegin { 
    self.dimmingView.alpha = 0.0f; 
    [self.containerView insertSubview:self.dimmingView atIndex:0]; 
    [self.dimmingView autoPinEdgesToSuperviewEdges]; 

    [self.presentedViewController.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { 
     self.dimmingView.alpha = 1.0f; 
    } 
                    completion:nil]; 
} 

- (void)dismissalTransitionWillBegin { 

    [self.presentedViewController.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { 
     self.dimmingView.alpha = 0.0f; 
    } 
                    completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { 
                     [self.dimmingView removeFromSuperview];                 }]; 
} 

面白い - とかなりイライラする - の事は私の提示ビューコントローラの仕事のためのプレゼンテーションと解雇アニメーションは予想通りとMyAnimationControllerに実装されていることです。私のディミングビューのフェードイン/アウトについては、提示されたビューコントローラをディスマウントするときにのみ機能します。プレゼンテーションを行うとき、フェードインはトランジションとともにアニメーションされませんが、単に一定の時間を使用します。私はAppleのドキュメントといくつかのチュートリアルに基づいてすべてを実装していると確信していますが、なんらかの理由でそれは単に期待どおりに動作しません。どのような問題が起こっているかについてのご意見はありますか?

答えて

1

は、私はあなたが使用したいと考えていpresentingViewControllertransitionCoordinatorのプレゼンテーションに、そしてpresentedViewConrollertransitionCoordinator解雇に。これは解雇時には機能しますが、現在実装されているようにプレゼンテーションではありません。

関連する問題