私が取り組んでいるプロジェクトでは、2 つのビュー コントローラー間のカスタム トランジションが必要です。次のようにメソッドをオーバーライドして、UIViewControllerTransitioningDelegate をセットアップして実装しました。
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC
{
//Creation of animation
id<UIViewControllerAnimatedTransitioning> animationController;
MyAnimator *animator = [[MyAnimator alloc] init];
animator.appearing = YES;
animationController = animator;
return animator
}
そして、メソッドをオーバーライドして UIViewControllerAnimatedTransitioning を正しく実装するように MyAnimator サブクラスをセットアップしました。
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
//custom transition animation
}
このアニメーション遷移をトリガーするために使用するセグエは、次のようにプログラムで作成および呼び出されます。
UIStoryboardSegue *segue = [[UIStoryboardSegue alloc] initWithIdentifier:@"showCardDetail" source:self destination:vc];
[self prepareForSegue:segue sender:self];
[segue perform];
プログラムでセグエを作成する理由: from (からの遷移) と to (への遷移) ビュー コントローラーを別々のストーリーボードに持っています。
問題/質問: 多くの例を見てきましたが、すべて次のようなストーリーボード セグエを使用してカスタム トランジションを処理します。
[self performSegueWithIdentifier:@"storyboardSegue-id" sender:self]
カスタム遷移が行われるように、上記のプログラムで作成されたセグエに対してメソッド-performでどのように定義する必要がありますか。