推出视图控制器后推视图控制器

我有这个导航堆栈

RootVC —> VC1 – >(出示) – > ModalVC

我有VC2 (不在导航堆栈中)。

在展示ModalVC时 ,我想点击我的ModalVC中的buttonclosuresModalVC,然后在VC1之后将VC2推入导航堆栈。 它应该是这样的:

RootVC —> VC1 —> VC2

我尝试了很多方法来制作它,但是只有当我返回到我的RootVC时才推动事件触发。

我试图与代表:

ModalVC上点击:

[self dismissViewControllerAnimated:YES completion:^{ if ([self.delegate respondsToSelector:@selector(dismissAndPush:)]) { [self.delegate performSelector:@selector(dismissAndPush:) withObject:VC2]; } }]; 

VC1

 - (void)dismissAndPush:(UIViewController *)vc { [self.navigationController pushViewController:vc animated:NO]; } 

请帮助理解这种行为。 我的错误在哪里?

其他错误。 如果我正确理解:解雇呈现的视图控制器之前的一些animation阻止导航堆栈中的animation。 我用两种方法解决了这个问题:

1)在解散之前删除或设置正确的animation

2)在导航控制器中使用setViewControllers(我select它)

 - (void)dismissAndPush:(UIViewController *)vc { [self dismissViewControllerAnimated:NO completion:^{ NSMutableArray *mutableControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers]; NSArray *controllers = [mutableControllers arrayByAddingObject:vc]; [self.navigationController setViewControllers:controllers animated:NO]; }]; } 

来自Apple文档 :

呈现视图控制器负责解除其呈现的视图控制器。

所以,VC1应该解散ModalVC,试着做到这一点

点击ModalVC:

  if ([self.delegate respondsToSelector:@selector(dismissAndPush:)]) { [self.delegate performSelector:@selector(dismissAndPush:) withObject:VC2]; } 

在VC1:

 - (void)dismissAndPush:(UIViewController *)vc { [self dismissViewControllerAnimated:YES completion:^{ [self.navigationController pushViewController:vc animated:NO]; }]; }