私は、モーダル表示されたビューコントローラのカスタムトランジションを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のドキュメントといくつかのチュートリアルに基づいてすべてを実装していると確信していますが、なんらかの理由でそれは単に期待どおりに動作しません。どのような問題が起こっているかについてのご意見はありますか?