我有一个自定义视图容器,它使用以下代码来关闭当前的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
外观方法永远不会被调用...
有什么建议吗?
答案 0 :(得分:0)
您永远不会将previousChildController.view
添加到self.view
。