0

我正在尝试重新启动动画,一旦您最小化应用程序然后重新打开它就会停止。因此,当我从 Xcode 重新启动应用程序时,它的动画效果很好,精灵上下摆动......但是当我用底部按钮关闭应用程序并打开它时,应用程序返回到它原来的 y 坐标然后停止。

函数 genie_animation 工作正常,就像我在下面的活动函数中调用了一个 NSLOG 并且它工作了,但动画没有。

我在以下位置调用了该函数applicationDidBecomeActive

 - (void)applicationDidBecomeActive:(UIApplication *)application
 {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
ViewController *vc;
vc = [[ViewController alloc] init];
[vc genie_animation];
}

然后这是我的动画代码:

-(void)genie_animation {
CGRect frm_up = tpl_genie.frame;
frm_up.origin.y -= 4;

[UIImageView animateWithDuration:1
                      delay:0.0
                    options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState
                 animations:^{
                     tpl_genie.frame = frm_up;
                 }
                 completion:nil
 ];
}
4

0 回答 0