如何推送两个视图控制器但只为第二个设置动画过渡? [英] How to push two view controllers but animate transition only for the second one?

查看:28
本文介绍了如何推送两个视图控制器但只为第二个设置动画过渡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 storyboard 中有三个控制器(FirstVC、SecondVC、ThirdVC),并且导航是顺序的:用户可以从 FirstVC 导航到 SecondVC,然后到 ThirdVC.现在,我需要制作一些按钮,可以从 FirstVC 打开 ThirdVC,但也会将 SecondVC 放在导航堆栈上,因此当用户从 ThirdVC 按下返回时,他将返回到 SecondVC.所以,我不需要从 FirstVC 到 SecondVC 的动画,只需要将 SecondVC 推送到导航控制器堆栈上,然后动画只转换到 ThirdVC.

I have three controllers (FirstVC, SecondVC, ThirdVC) inside storyboad, and navigation is sequential: a user can navigate from FirstVC to SecondVC, and then to ThirdVC. Now, I need to make some button that will open ThirdVC from FirstVC but will also put SecondVC on navigation stack, so when a user will press back from ThirdVC he will be returned to SecondVC. So, I don’t need animation from FirstVC to SecondVC, just need to push SecondVC on navigation controller stack and then animate only transition to ThirdVC.

我无法找到如何禁用 performSegueWithIdentifier 动画,所以我想我应该手动从情节提要中实例化 SecondVC,将其放在导航堆栈上,然后为 ThirdVC 执行 performSegueWithIdentifier.任何想法如何做到这一点?

I was unable to find how disable animation for performSegueWithIdentifier, so I’m thinking I should instantiate SecondVC from storyboard manually, put it on navigation stack, and then perform performSegueWithIdentifier for ThirdVC. Any ideas how to do that?

推荐答案

如果你是第一个VC,你正在寻找的解决方案:

The solution you're looking for if you're in the firstVC:

NSMutableArray *controllers = [self.navigationController.viewControllers mutableCopy];
[controllers addObject:secondVc];
[controllers addObject:thirdVC];
[self.navigationController setViewControllers:controllers animated:YES];

这将在 thirdVC 中进行动画处理,而 secondVc 在该过程中不可见.当用户按下后退按钮时,他们将返回到 secondVc

This will animate in the thirdVC without the secondVc becoming visible in the process. When the user press the back button, they will return to the secondVc

这篇关于如何推送两个视图控制器但只为第二个设置动画过渡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆