我有一个自定义视图容器,它使用以下代码来关闭当前的 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
外观方法永远不会被调用......
有什么建议么?