0

我在我的一个视图中将这段代码用于动画:

animation.animationImages= [NSArray arrayWithObjects:
                                [UIImage imageNamed:@"Frame0.png"],
                                [UIImage imageNamed:@"Frame1.png"],
                                [UIImage imageNamed:@"Frame2.png"],
                                [UIImage imageNamed:@"Frame3.png"],
                                [UIImage imageNamed:@"Frame4.png"],
                                [UIImage imageNamed:@"Frame5.png"],
                                [UIImage imageNamed:@"Frame6.png"],
                                [UIImage imageNamed:@"Frame7.png"],
                                [UIImage imageNamed:@"Frame8.png"],
                                [UIImage imageNamed:@"Frame9.png"],
                                [UIImage imageNamed:@"Frame10.png"],
                                [UIImage imageNamed:@"Frame11.png"],
                                [UIImage imageNamed:@"Frame12.png"],
                                [UIImage imageNamed:@"Frame13.png"],
                                [UIImage imageNamed:@"Frame14.png"],
                                nil];

    [animation setAnimationRepeatCount:1];
    animation.animationDuration = 1;
    [animation startAnimating];

现在我需要说明动画何时结束出现 2 个按钮,“菜单”和“重播”我是否使用停止动画或其他东西,请帮助和解释,因为我是初学者,感谢您的帮助:)

4

2 回答 2

1

好吧,您的动画持续时间是 1 秒,因此您可以执行以下操作:

animation.animationImages= [NSArray arrayWithObjects:
                                [UIImage imageNamed:@"Frame0.png"],
                                [UIImage imageNamed:@"Frame1.png"],
                                [UIImage imageNamed:@"Frame2.png"],
                                [UIImage imageNamed:@"Frame3.png"],
                                [UIImage imageNamed:@"Frame4.png"],
                                [UIImage imageNamed:@"Frame5.png"],
                                [UIImage imageNamed:@"Frame6.png"],
                                [UIImage imageNamed:@"Frame7.png"],
                                [UIImage imageNamed:@"Frame8.png"],
                                [UIImage imageNamed:@"Frame9.png"],
                                [UIImage imageNamed:@"Frame10.png"],
                                [UIImage imageNamed:@"Frame11.png"],
                                [UIImage imageNamed:@"Frame12.png"],
                                [UIImage imageNamed:@"Frame13.png"],
                                [UIImage imageNamed:@"Frame14.png"],
                                nil];

    [animation setAnimationRepeatCount:1];
    animation.animationDuration = 1;
    [animation startAnimating];
    [self performSelector:@selector(didFinishAnimating) withObject:nil afterDelay:1.0];


-(void) didFinishAnimating {
   //animation ended add some buttons
}
于 2012-07-29T18:05:17.813 回答
0

动画结束后,您可以使用 NSTimer 调用另一个方法,使用相同的时间间隔购买 NSTimer 和 animationDuration 属性。

animation.animationImages= [NSArray arrayWithObjects:
                            [UIImage imageNamed:@"Frame0.png"],
                            [UIImage imageNamed:@"Frame1.png"],
                            [UIImage imageNamed:@"Frame2.png"],
                            [UIImage imageNamed:@"Frame3.png"],
                            [UIImage imageNamed:@"Frame4.png"],
                            [UIImage imageNamed:@"Frame5.png"],
                            [UIImage imageNamed:@"Frame6.png"],
                            [UIImage imageNamed:@"Frame7.png"],
                            [UIImage imageNamed:@"Frame8.png"],
                            [UIImage imageNamed:@"Frame9.png"],
                            [UIImage imageNamed:@"Frame10.png"],
                            [UIImage imageNamed:@"Frame11.png"],
                            [UIImage imageNamed:@"Frame12.png"],
                            [UIImage imageNamed:@"Frame13.png"],
                            [UIImage imageNamed:@"Frame14.png"],
                            nil];

[animation setAnimationRepeatCount:1];
animation.animationDuration = 1;
[animation startAnimating];
[NSTimer  scheduledTimerWithTimeInterval:1
                                  target:self
                                selector:@selector(showOtherButtonsAfterAnimation:)
                                userInfo:nil
                                 repeats:NO];

NSTimer 将在选定的时间间隔(1 秒)后调用您在目标对象(self)的 selector(showOtherButtonsAfterAnimation:) 中设置的方法。showOtherButtonsAfterAnimation: 方法需要有一个 NSTimer 参数,即使您从未在该方法中使用它。

-(void)showOtherButtonsAfterAnimation:(NSTimer*)theTimer { .... whatever ..... }
于 2012-07-29T18:11:07.907 回答