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

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

问题描述

我在storyboad中有三个控制器(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的动画,所以我想我应该手动从storyboard中实例化SecondVC,将它放在导航堆栈上,然后执行performSegueWithIdentifier for ThirdVC。任何想法如何做?

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];

这将在第三个VC中设置动画,而不会在此过程中显示第二个VC。当用户按下后退按钮时,它们将返回到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天全站免登陆