How to push two view controllers but animate transition only for the second one?(如何推送两个视图控制器但只为第二个设置动画过渡?)
问题描述
我在 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
这篇关于如何推送两个视图控制器但只为第二个设置动画过渡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何推送两个视图控制器但只为第二个设置动画过渡?


- android 4中的android RadioButton问题 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01