2012-08-31 44 views
0

在我的应用程序中有一个动画。当我按下按钮时,动画(让一个盒子从左到右移动)执行,并且ViewController由“pushViewContreller”更改。我想要的是,当我从secondViewController使用popViewController时,应该打开firstViewController并且该框应该从右向左移动(反向操作)。提前致谢。iPhone开发:向后播放动画

+1

你试图扭转改变的动画导航控制器机视? –

回答

0

在导航之前,保存框的开始位置和结束位置,当您返回时,将框从结束位置移动到开始位置。

0

如果你想移动一个盒子,那么你可以使用这段代码。 首先让两个CGRect说CGRect left和CGRect吧。

然后在viewWillAppear of firstViewController中写下这段代码。

 CGRect left = //Your left side Frame 
     CGRect right = //Your right side frame 
     if (CGRectContainsPoint(right, YourObject.center)) 
     { 

      [UIView animateWithDuration:0.3 animations:^{ 

       [YourObject setFrame:left]; 

      }]; 
     } 

在这段代码viewWillAppear中会打电话给你每次当你弹出secondViewController,如果你的机器会在右边它会使服用它离开动画。按钮点击

编写代码

 CGRect left = //Your left side Frame 
     [UIView animateWithDuration:0.3 animations:^{ 

      [YourObject setFrame:left]; 

     }]; 

希望你会使用这个代码后高兴........