我在 storyboard 中有三个 Controller (FirstVC、SecondVC、ThirdVC),并且导航是顺序的:用户可以从 FirstVC 导航到 SecondVC,然后到 ThirdVC。现在,我需要制作一些按钮,可以从 FirstVC 打开 ThirdVC,但也会将 SecondVC 放在导航堆栈上,因此当用户从 ThirdVC 按下返回时,他将返回到 SecondVC。所以,我不需要从 FirstVC 到 SecondVC 的动画,只需要将 SecondVC 推送到导航 Controller 堆栈上,然后动画只转换到 ThirdVC。
我无法找到如何禁用 performSegueWithIdentifier 动画,所以我想我应该手动从 Storyboard 中实例化 SecondVC,将其放在导航堆栈上,然后为 ThirdVC 执行 performSegueWithIdentifier。任何想法如何做到这一点?
最佳答案
如果您在 firstVC 中,您正在寻找的解决方案:
NSMutableArray *controllers = [self.navigationController.viewControllers mutableCopy];
[controllers addObject:secondVc];
[controllers addObject:thirdVC];
[self.navigationController setViewControllers:controllers animated:YES];
这将在 thirdVC 中进行动画处理,而 secondVc 在该过程中不可见。当用户按下后退按钮时,他们将返回到 secondVc
关于ios - 如何推送两个 View Controller 但只为第二个设置动画过渡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21857222/