iOS 6自定义容器视图控制器
我有一个自定义视图容器,它使用以下代码关闭当前的viewController并显示上一个iOS 6自定义容器视图控制器,ios,ios6,uiviewcontroller,Ios,Ios6,Uiviewcontroller,我有一个自定义视图容器,它使用以下代码关闭当前的viewController并显示上一个 - (void)popToViewControllerwithAnimation:(AnimationStyle)animation { if(self.currentChildIndex == 0) return; UIViewController *currentChildController = self.childViewControllers[self.curre
- (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
appearance方法从未被调用外,其他方法都工作正常
有什么建议吗?您从未将
previousChildController.view
添加到self.view
它添加到我的演示文稿代码中,我不会处理它。好吧,保留实例,但是从超级视图中删除它,并在需要时添加它。转换工作正常-我返回到我需要的状态,但调用的视图将出现:
/视图显示:
除外。我移动了它,并将addSubview:
放入此方法,但它们仍然没有启动。对不起,我没有使用“removeFromSuperview”,我只是再次添加它-我真傻。我认为这是大致可行的-然而我的动画现在都搞砸了-修复一件事来打破下一天的秩序。动画延迟在代码片段中是0.0-检查这一点。另一件事是您需要添加上一个视图控制器的视图,并触发动画。