如果不使用UIViewAnimation,removeFromSuperview会崩溃

时间:2013-07-12 16:03:05

标签: ios uiview uiviewcontroller uiviewanimation

我遇到了一个奇怪的问题。我使用removeFromSuperview导致我的应用粉碎。但是如果我使用[UIView animationWithDuration],它就没问题了。

见下文这可以成功运行。

   [self willMoveToParentViewController:nil];

     [UIView animateWithDuration:0.5 animations:^(void){

         CATransition *transition = [CATransition animation];
         transition.type = kCATransitionReveal;
         transition.subtype = kCATransitionFromBottom;
         transition.duration = 0.5;
         [self.view.superview.layer addAnimation:transition forKey:nil];


     } completion:^(BOOL finished){
         [self.view removeFromSuperview];
         [self removeFromParentViewController];
     }] ;

但如果我像这样删除[UIView animationWithDuration]。

    [self willMoveToParentViewController:nil];

     [self.view removeFromSuperview];
     [self removeFromParentViewController];

它已经崩溃了。

以下是我添加子视图的方法

 [self.tabBarController addChildViewController: vc];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromTop;
transition.duration = 0.5;
[self.tabBarController.view.layer addAnimation:transition forKey:nil];
[self.tabBarController.view addSubview:vc.view];
[self.tabBarController didMoveToParentViewController:vc];

我不知道为什么会这样。希望可以有人帮帮我 。这是一个奇怪的问题。 enter image description here

0 个答案:

没有答案