Mat*_*ijn 6 animation transition objective-c ios segue
我有以下设置:

红色控制器有一个方法
- (IBAction)unwindToRed:(UISegue *)segue
Run Code Online (Sandbox Code Playgroud)
和a
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier
Run Code Online (Sandbox Code Playgroud)
返回此事件的自定义segue.
在我的自定义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];
}
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我已经设置了一个转换委托,而后者又会调用它
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
Run Code Online (Sandbox Code Playgroud)
在我应用自定义动画的动画控制器上.但是现在当我在黄色视图上点击Unwind to Red时,它只会"展开"到它的父级.(例如蓝色的).
当我将自定义segue从等式中移开时,它可以正常工作.它一路走到顶端.
现在我认为这与此有关
[source dismissViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)
因为那通常只是"一上去"我的问题是我认为,我应该在那里打电话,以便在需要时一直到红色?黄色是模态叠加.所以"pop too root"是行不通的.
您想使用导航控制器的 popToViewController:
[source.navigationController popToViewController:destination animated:YES];
Run Code Online (Sandbox Code Playgroud)
或者,使用animated:NO并将整个内容放入动画块中:例如:
UIViewAnimationOptions animation = UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowAnimatedContent;
UIViewController *source = (UIViewController *) self.sourceViewController;
UIViewController *dest = (UIViewController *) self.destinationViewController;
[UIView transitionWithView:src.navigationController.view duration:0.4
options: animation
animations:^{
[source.navigationController popToViewController:dest animated:NO];
}
completion:^(BOOL finished) {
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4025 次 |
| 最近记录: |