【发布时间】:2015-02-27 20:43:32
【问题描述】:
我正在处理的项目需要在两个视图控制器之间进行自定义转换。我已经通过覆盖以下方法设置并实现了 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
}
我已经设置了 MyAnimator 子类,通过重写方法正确实现 UIViewControllerAnimatedTransitioning:
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
//custom transition animation
}
我用来触发动画转换的 segue 是通过编程方式创建和调用的,例如:
UIStoryboardSegue *segue = [[UIStoryboardSegue alloc] initWithIdentifier:@"showCardDetail" source:self destination:vc];
[self prepareForSegue:segue sender:self];
[segue perform];
以编程方式创建 segue 的原因:我在不同的故事板中有 from(transition from) 和 to(transition to) 视图控制器。
问题/问题: 我见过很多例子,都使用故事板 segue 处理自定义转换,例如:
[self performSegueWithIdentifier:@"storyboardSegue-id" sender:self]
我应该如何在 -perform 方法中为上面以编程方式创建的 segue 定义,以便发生自定义转换。
【问题讨论】:
标签: ios objective-c iphone segue custom-transition