ios - 如何推送两个 View Controller 但只为第二个设置动画过渡?

标签 ios objective-c cocoa-touch storyboard uikit

我在 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/

相关文章:

iphone - 如何访问附加到 UIGestureRecognizer 的选择器的名称?

iphone - 获取包含在 NSString 中的文件的扩展名

iphone - 通过 Objective-C 选择器回调

android - Android 广播接收器的 IOS 等效项

iphone - 如何在 iOS 中用渐变填充用 CGPoints 定义的形状?

javascript - 将 Iframe 嵌入图像内

ios - 如何解决像 'NULL cString' 这样的崩溃?

objective-c - 反编译 Objective-C 库

iphone - NSString @property,使用复制而不是保留

ios - 对许多对象执行相同的操作