1

我有一个动画可以在 iPad 应用程序的主菜单屏幕中使用。选择一些菜单项时,应用程序将推动新视图“导航控制器”。当我想在按下后退按钮并再次返回主菜单的那一刻再次重新启动动画时,就会出现问题。

我试图将动画代码放在这些方法中:

-(void) viewDidLoad  

-(void) viewDidAppear

但我不能让他们工作。

我想做的是在背景中动画公司的标志。

我的代码是:

[UIView beginAnimations:nil context:NULL];    
[UIView setAnimationDuration:15.0];
[UIView setAnimationRepeatCount:20.0f];
[UIView setAnimationRepeatAutoreverses:YES];

CGPoint pos = large_bright.center; 
pos.x = 400.0f;
large_bright.center = pos;
CGPoint pos2 = large_dim.center; 
pos2.x = -10.0;
large_dim.center = pos2;
[UIView commitAnimations];
4

3 回答 3

0

尝试:

[UIView animateWithDuration:1.0 // set here how fast u want it to animate
                 animations:^{ 
                     // add your needed animation here

                 } 
                 completion:^(BOOL finished) {  
                     // do some stuff when its done if you need to
                 }    
 ];
于 2012-07-09T12:52:55.580 回答
0

you should call

  • (void)viewWillAppear:(BOOL)animated;
于 2012-07-09T13:14:29.570 回答
-1

从 viewDidLoad 和 viewDidAppear 调用其他函数。然后在该函数中添加您的动画代码。

-(void) viewDidLoad
{
   [self add_animation];
}
-(void)animation
{
   //your animation code
}
于 2012-07-09T12:52:43.023 回答