【发布时间】:2014-08-23 05:13:04
【问题描述】:
我有以下设置:
红色控制器有方法
- (IBAction)unwindToRed:(UISegue *)segue
还有一个
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier
返回此事件的自定义转场。
在我的自定义 segue 中,我在执行代码中有以下内容:
- (void)perform
{
// Just helpers to get the controllers from the segue
UIViewController *destination = self.destinationViewController;
UIViewController *source = self.sourceViewController;
// Setting transitioning delegate for custom transitions
destination.transitioningDelegate = self;
source.transitioningDelegate = self;
destination.modalTransitionStyle = UIModalPresentationCustom;
source.modalPresentationStyle = UIModalPresentationCurrentContext;
// When I am transitioning to a new one
if(!self.reversed)
{
[source presentViewController:destination animated:YES completion:nil];
}
// Or reversing from a current one
else
{
[source dismissViewControllerAnimated:YES completion:nil];
}
}
如您所见,我已经设置了一个转换委托,该委托又调用了
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
在我应用自定义动画的动画控制器上。但是现在当我在黄色视图上点击 Unwind to Red 时,它只会“展开”到其父级。 (例如蓝色的)。
当我将自定义转场排除在等式之外时,它工作得很好。它一直通向顶部。
现在我认为这与
有关[source dismissViewControllerAnimated:YES];
line,因为这通常只是“上升”,所以我的问题是,我应该在那里调用什么,以便在需要时一直上升到红色?黄色是模态叠加。所以“pop too root”是行不通的。
【问题讨论】:
-
您的
transitionContext在源、目标、框架和容器方面如何?我认为你不应该使用[source dismissViewControllerAnimated:YES];,你应该打电话给[transitionContext completeTransition:YES];
标签: ios objective-c animation transition segue