【问题标题】:animationDidStop set but not being called (iPhone app coding)animationDidStop 设置但未被调用(iPhone 应用程序编码)
【发布时间】:2009-07-20 07:03:39
【问题描述】:
#import "MyViewController.h"

@implementation MyViewController
@synthesize menuView, gameView, helpView, optionsView, gameButton, helpButton, optionsButton;

- (void) viewDidLoad {
[self setView:menuView];
}

 - (IBAction)gotoGame {
[UIView beginAnimations:@"buttonSlide" context: nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDidStopSelector:@selector(animationDidStop)];
gameButton.center = CGPointMake(104,1000);
[UIView commitAnimations];
 }

- (IBAction)gotoHelp {
[self setView:helpView];
}

- (IBAction)gotoOptions {
[self setView:optionsView];
}

- (void)animationDidStop {
NSLog(@"why is this not working?");
[self setView:gameView];
}


@end

不确定什么会有帮助,所以我包含了整个 .m 文件。无论如何,我是 iPhone 应用程序开发的新手,我正在努力完成我的动画。动画本身完美运行,但方法 animationDidStop 拒绝被调用..即使我使用 setAnimationDidStopSelector 就像它在文档中显示的那样。我知道视图更改有效,因为当我将它放在 gotoGame {} 中的动画之后时,它会切换,但这会导致动画不显示。

有人可以帮我在动画停止后调用该方法,还是使用计时器在必要的时间后调用它? (我也尝试过这种方法,但没有运气)。

【问题讨论】:

  • 没关系,我错过了:[UIView setAnimationDelegate:self];
  • 您应该将其发布为答案并接受它。

标签: iphone objective-c cocoa cocoa-touch animation


【解决方案1】:

不仅[UIView setAnimationDelegate:self] 必须被调用,而且如果动画的调用方法是静态的,委托也必须是静态的。大多数示例使用非静态方法来调用动画,因此如果您使用静态方法来制作动画,这可能会令人困惑(至少对我而言)。

【讨论】:

  • 感谢这个......在我设置委托之前对我不起作用:)
【解决方案2】:

添加[UIView setAnimationDelegate:self];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多