我的要求是当我从屏幕右侧滑动时(视图控制器 A)然后需要使用交互式转换推送到下一个视图控制器(视图控制器 B)。当我从屏幕左侧滑动时(视图控制器 B)也使用相同的关闭机制它使用交互式转换关闭控制器。如何以正确的方式实现它。我已经使用交互式转换实现了关闭视图控制器,但无法使用交互式转换实现推送到视图控制器
#import "AMSimpleAnimatedDismissal.h"
@implementation AMSimpleAnimatedDismissal
-(NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext
{
return 1.5f;
}
-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
[[transitionContext containerView]addSubview:toVC.view];
CGRect toFrame = toVC.view.frame;
CGRect initialFrame = fromVC.view.frame;
toVC.view.frame = CGRectMake(-320 ,0, CGRectGetWidth(toFrame) , CGRectGetHeight(toFrame));
CGRect finalFrame = CGRectMake(initialFrame.size.width, initialFrame.origin.y, initialFrame.size.width, initialFrame.size.height);
UIViewAnimationOptions opts = UIViewAnimationOptionCurveLinear;
[UIView animateWithDuration:1.0 delay:0 options:opts animations:^{
fromVC.view.frame = finalFrame;
toVC.view.frame = CGRectMake(0, 0, CGRectGetWidth(fromVC.view.frame), CGRectGetHeight(fromVC.view.frame));
} completion:^(BOOL finished) {
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}];
}
这些是我的交互式过渡部分的代码行