2

我有一个自定义视图容器,它使用以下代码来关闭当前的 viewController 并呈现前一个......

- (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];

        }];

    }
}

一切正常,除了previousViewController外观方法永远不会被调用......

有什么建议么?

4

1 回答 1

0

你永远不会添加previousChildController.viewself.view.

于 2013-07-10T12:13:33.510 回答