3

私はViewControllerが言うことができViewControllerA、ViewControllerが言うことができますViewControllerB

ViewControllerBViewControllerAカスタムトランジションを使用してモーダルに表示されます。

ViewControllerA で:

-(void)buttonClicked...
{
  ViewControllerB * controller = [[ViewControllerB alloc] init];
  [controller setModalPresentationStyle:UIModalPresentationCustom];
  controller.transitioningDelegate = self;
  [self presentViewController:controller animated:YES completion:nil];
}

ViewControllerA で -

#pragma mark - UIViewControllerTransitioningDelegate

- 

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

   FadeInWithPopAnimator* fadeInAnimator = [[FadeInWithPopAnimator alloc] init];
   return fadeInAnimator;
 }

FadeInWithPopAnimatortransitionDuration および animationTransition メソッドを実装するカスタム Animator クラスを呼び出しました。

提示されたビューコントローラーでいくつかのビューをアニメーション化したい -ViewControllerB遷移アニメーションが開始されてから 0.2 秒後。

私はオンラインでドキュメントを読みましたが、transitionCoordinator を使用する方法が適しているようです。しかし、どこにコードを置くべきですか?

ViewControllerA1) ?で presentViewController を呼び出している間。

2)アニメータークラスで?

3) のビューで表示されViewControllerAますか?

いくつか試してみましたが、結果が得られず、例を見つけるのが困難です。

4

1 に答える 1

2

提示されたView ControllerのTransitionCoordinatorは、View Controllerのアニメーションが開始された後に設定されるためviewWillAppear、提示されたView Controllerの. animateAlongsideTransition:completion:トランジション コーディネーターを使用して、追加のアニメーションを追加します。あなたの場合、ViewControllerB:

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear];

    [self.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {

        // change any properties on your views

    } completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {


    }];
}
于 2016-08-24T10:44:29.570 に答える