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
这篇关于如何推送两个视图控制器但只为第二个设置动画过渡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何推送两个视图控制器但只为第二个设置动画过渡?
基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01