Multi-Controller Management and Controller Management
// Add the child view controller FirstViewController * firstViewController = [[FirstViewController alloc] initWithNibName: @ "FirstViewController" bundle: nil] in the parent view controller; [self addChildViewController: firstViewController]; secondViewController * secondViewController = [[SecondViewController alloc] listener: @ "SecondViewController" bundle: nil]; [self addChildViewController: secondViewController]; Role * ThirdViewController = [[thirdViewController alloc] listener: @ "ThirdViewController" bundle: nil]; [self addChildViewController: thirdViewController]; [self. view addSubview: thirdViewController. view]; // addChildViewController calls [child willMoveToParentViewController: self] Back, but does not call didMoveToParentViewController. Therefore, you need to call [thirdViewController preview: self]; currentViewController = thirdViewController; // switch the child view controller [self transitionFromViewController: currentViewController toViewController: firstViewController duration: 4 options: UIViewAnimationOptionTransitionFlipFromLeft animations :{} completion: ^ (BOOL finished) {// ......}]; currentViewController = firstViewController; // remove child view controller // removeFromParentViewController does not call [self willMoveToParentViewController: nil] Before removing child. Therefore, you need to call [currentViewController willMoveToParentViewController: nil]. [currentViewController removeFromSuperview]; [currentViewController removeFromParentViewController];