Ios 如何使用动画将一个ChildViewController推送到另一个ChildViewController

Ios 如何使用动画将一个ChildViewController推送到另一个ChildViewController,ios,objective-c,childviewcontroller,Ios,Objective C,Childviewcontroller,我是iOS的初学者。在我的ParentViewController中,我添加了一个ChildViewController。在该控制器中,我添加了一个“下一步”按钮。单击该按钮时,我将第一个ChildViewController按到第二个ChildViewController。那很好 但在这里,我在第二个ChildViewController中添加了另一个按钮。当我点击该按钮时,我想从第二个ChildViewController向后推到第一个ChildViewController。但我的代码不起作

我是iOS的初学者。在我的ParentViewController中,我添加了一个ChildViewController。在该控制器中,我添加了一个“下一步”按钮。单击该按钮时,我将第一个ChildViewController按到第二个ChildViewController。那很好

但在这里,我在第二个ChildViewController中添加了另一个按钮。当我点击该按钮时,我想从第二个ChildViewController向后推到第一个ChildViewController。但我的代码不起作用。请帮帮我

我的代码: ParentViewController: 儿童视图控制器1: 儿童视图控制器2:
在这里,当我单击此后退按钮时,它不会将其向后推。

在ChildViewController2后退按钮操作中,您有:

 ChildViewController2 *middleVC =[self.storyboard instantiateViewControllerWithIdentifier:@"ChildViewController2"];
你不是说:

ChildViewController1 *middleVC =[self.storyboard instantiateViewControllerWithIdentifier:@"ChildViewController1"];

一旦你从孩子1推到孩子2,你可以弹出孩子2,所以孩子1将显示!!为什么要推到child1?嗨,T先生,我在这里使用动画查看我的以上代码仅在中使用动画必须从Child2向后推到child1是的,当我单击“后退”按钮时您的右键我想从Child2向后推到child1如果您知道此问题的解决方案,请帮助meSo为什么要在其自己的方法中添加ViewController2?为什么不添加ViewController1呢?似乎我们得到了ViewController2的两个实例,只是将其中一个移走,再次暴露自己…?是的,你说得对,但我希望你能解决这个问题
#import "ChildViewController2.h"

@interface ChildViewController2 ()
{

}

@end

@implementation ChildViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction)back:(id)sender {

    ChildViewController2 *middleVC =[self.storyboard instantiateViewControllerWithIdentifier:@"ChildViewController2"];

    middleVC.view.hidden=FALSE;

    [middleVC.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

    [self addChildViewController:middleVC];
    [self.view addSubview:middleVC.view];
    [middleVC didMoveToParentViewController:self];

    [UIView animateWithDuration:0.5 animations:^{
        [middleVC.view setFrame:CGRectMake(self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.height)];
    }];
}
 ChildViewController2 *middleVC =[self.storyboard instantiateViewControllerWithIdentifier:@"ChildViewController2"];
ChildViewController1 *middleVC =[self.storyboard instantiateViewControllerWithIdentifier:@"ChildViewController1"];