简体   繁体   中英

iOS 6 Custom Container View Controller

I have a custom view container that use the following code to dismiss the current viewController and present the previous one...

- (void)popToViewControllerwithAnimation:(AnimationStyle)animation
{
    if(self.currentChildIndex == 0)
        return;

    UIViewController *currentChildController = self.childViewControllers[self.currentChildIndex];

    self.currentChildIndex--;

    UIViewController *previousChildController = self.childViewControllers[self.currentChildIndex];

    if(animation == kSlideRight || animation == kSlideDown) {

        CGRect onScreenFrame = self.view.bounds;

        CGRect offScreenFrame = self.view.bounds;

        CGFloat duration = 0.35;

        if(animation == kSlideRight) {

            offScreenFrame.origin.x += offScreenFrame.size.width;

            duration = 0.3;
        }

        if(animation == kSlideDown)
            offScreenFrame.origin.y += offScreenFrame.size.height;

        [currentChildController willMoveToParentViewController:nil];

        [self addChildViewController:previousChildController];

        [UIView animateWithDuration:duration delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{

        currentChildController.view.frame = offScreenFrame;

        previousChildController.view.transform = CGAffineTransformIdentity;

        previousChildController.view.frame = onScreenFrame;

        } completion:^(BOOL finished) {

            [currentChildController.view removeFromSuperview];

            [currentChildController removeFromParentViewController];

            [previousChildController didMoveToParentViewController:self];

        }];

    }
}

All is working fine except the previousViewController appearance methods never get called...

Any suggestions?

您永远不会将previousChildController.view添加到self.view

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM